Difference between revisions of "Prototyping with Microcontrollers, Sensors, and Materials"

From EG1004 Lab Manual
Jump to: navigation, search
(165 intermediate revisions by 7 users not shown)
Line 1: Line 1:
= Objective =
= Objective =
The objective of this lab is to utilize electronic components, an Arduino board, and the Arduino IDE (Integrated Development Environment) to control an LED without and with a button, to take temperature readings, and to design a prototype for a product. The Arduino IDE will be used to program the Arduino board.
This is a competition lab that will require designing an effective thermal insulation device.  An Arduino board and other electronic components will be used to design the device. Data analysis will be performed to see if the device slowed the rate of heat loss from a container of melted wax placed inside it. The performance of the device will be rated by a design ratio that uses the cost of the device, insulating capacity, the final temperature of the melted wax, and the room temperature. The lowest ratio wins the competition.
 
The prototyping will focus on designing and building a thermal insulation device that will be tested and the resulting data analyzed. All designs will be tested for their capacity to slow the rate of heat loss from melted wax placed inside them. The design will be entered in a competition that will be judged by a ratio that uses the cost of the device, its insulating capacity, the final temperature of the melted wax inside the device, and the room temperature. The lowest ratio wins.


= Overview =
= Overview =
Line 8: Line 6:
== Prototyping ==
== Prototyping ==


<b>Prototyping</b> is the process of designing and building an early model of a product to test a concept or process. Any system or device that will be sold to consumers, government agencies, or businesses will begin as a prototype that typically does not have all of the components or functions that will be used in the product that is eventually brought to market. A prototype can serve as a proof of concept showing that the system or device can be built and will perform correctly. In this lab, a prototype of a thermal insulation device will be built. Its function will be to reduce the rate of heat loss from a container of heated wax placed in the device. The prototype insulating device will use a thermistor to measure heat loss and it will be operated by a microcontroller.  
Prototyping is the process of designing and building an early model of a product to test it. Any system or device that will be sold to consumers, government agencies, or businesses will begin as a prototype that typically does not have all of the components or functions that will be used in the final product that is brought to market. A prototype can serve as a proof of concept showing that the system or device can be built and will perform correctly.
 
In this lab, a prototype of a thermal insulation device will be built. Its function will be to reduce the rate of heat loss from a container of heated wax that will be placed in the device. The prototype insulating device will use a TMP 36 sensor to measure heat loss and it will be operated by a microcontroller.


== Electricity ==
== Electricity ==
<b>Electricity</b> is the movement of electrons. Electrons flow through a conductive wire when there is a difference in charge between two points in the wire. This flow of electrons is the <b>electrical current</b> and it is measured in amperes (A). Due to convection, electrical current flows in the opposite direction of the electrons. The difference in charge is the <b>electrical voltage</b> and is measured in volts (V). Certain materials resist that flow of electrons. This property is <b>electrical resistance</b> and is measured in ohms (&Omega;). Ohm’s Law (1) describes the relationship of the voltage across a resistor, the current (I) flowing through a resistor, and the resistance (R) of the resistor.
Electricity is the movement of electrons. Electrons flow through a conductive wire when there is a difference in charge between two points in the wire. This flow of electrons is the electrical current and it is measured in amperes (A). Electrical current flows in the opposite direction of the electrons. The difference in charge is the electrical voltage and is measured in volts (V). Certain materials resist the flow of electrons. This property is electrical resistance and is measured in ohms (Ω).
 
Ohm’s Law (1) describes the relationship of the voltage across a resistor, the current (I) flowing through a resistor, and the resistance (R) of the resistor.
<center><math>V=I*R</math></center>
<center><math>V=I*R</math></center>
<p style="text-align:right">(1)</p>
<p style="text-align:right">(1)</p>


Variations in voltage and current are also used in digital signal processing to operate complex systems and devices and simpler devices, such as microcontrollers and household digital instruments.
Variations in voltage and current are used in digital signal processing to operate complex systems and devices and simpler devices, such as microcontrollers and household digital instruments.
 
== Electrical Components ==


== Electronic Components ==
Several basic electrical components are used to build simple circuits.


Several basic electronic components are used to build simple circuits. Some of these components are polarized, which means the way they are connected affects their functionality.
=== Breadboards ===
Breadboards (Figure 1) are small boards that are commonly used for circuit prototyping. They allow the circuit’s components to be connected without making permanent connections. The red and blue strips on the sides of the board (sections A and D) are called power rails and are connected down the board, usually used for powering and grounding. The non-colored rows between the power and ground strips (sections B and C) are connected across and are usually used for making the connections between components. Sections B and C are not connected to each other across the bridge in the middle of the board.
 
[[Image:breadboard.jpg|500px|thumb|center|Figure 1: Breadboard Connections]]


=== DC (Direct Current) Voltage Sources ===
=== DC (Direct Current) Voltage Sources ===


<b>DC voltage sources</b> are used to power circuits because they have a voltage difference across their terminals. DC voltage sources are usually batteries (e.g. AA, AAA). Arduino boards can be powered by a battery, a USB cable, or an AC adapter. When the Arduino is powered, it can be used as a 5V DC voltage source. They are polarized.
DC voltage sources are used to power circuits because they have a voltage difference across their terminals. DC voltage sources are usually batteries (e.g. AA, AAA). Arduino boards can be powered by a battery, a USB cable, or an AC adapter. When the Arduino is powered, it can be used as a 5V DC voltage source.


=== Resistors ===
=== Resistors ===


<b>Resistors</b> (Figure 1) are components that reduce the current flowing through a circuit and convert the excess current to thermal energy. Resistors can be used to control the voltage and current of circuits. Resistors are color coded to indicate their resistance (Figure 2). They are not polarized.
Resistors (Figure 2) are components that reduce the current flowing through a circuit and convert the excess current into thermal energy. They are one of the most common components in electrical circuits. Resistors are mainly used to limit the current flowing through a component. For example, when connecting an LED to a battery, a resistor helps limit the circuit to ensure the LED is not damaged.


[[Image:resistor.jpg|center]]
[[Image:Resistor and symbol.png|center|thumb|center|300px|Figure 2: Resistor (I) & Resistor Symbol (r) used in Circuit Diagrams]]
<center><p>Figure 1: Symbol for a Resistor</p></center>


[[Image:Resistor color code.png‎|thumb|center|360px|Figure 2: Resistor Color Codes]]
Resistors are color coded to indicate their resistance in ohms (Figure 3). They are not polarized, meaning the orientation of the resistor does not affect the circuit.


A <b>thermistor</b> (Figure 3) is a thermal resistor that is used to measure temperature. The voltage in the thermistor will change proportionally to the temperature. The output voltage can then be converted to a temperature reading.
[[Image:Resistor color code.png‎|thumb|center|500px|Figure 3: Resistor Color Codes (zachpoff.com)]]


[[Image:Thermistor.jpg‎|thumb|center|300px|Figure 3: Thermistor]]
=== Push-Buttons and Switches ===


=== Push-Buttons and Switches ===
Push-buttons and switches (Figure 4) are mechanical devices that interrupt or divert current. Basic push-buttons are polarized while basic switches are not.
 
[[Image:Lab_Push_button_Proto.png|375px|thumb|center|Figure 4: A Push Button, and its Internal Switch Circuit]]
 
=== Diodes ===
 
Diodes allow current to pass in only one direction. The anode is the positive terminal of the diode, and the cathode is the negative terminal. Diodes can also be used to amplify signals (Figure 5).


<b>Push-buttons</b> and <b>switches</b> (Figure 4) are mechanical devices that interrupt or divert current. Basic push-buttons are polarized while basic switches are not.
[[Image:Anode_cathode_current_flow.png |350px|thumb|center|Figure 5: A Diode and its Corresponding Symbol]]
[[Image:button_switch.jpg|375px|thumb|center|Figure 4: Symbols for Buttons and Switches]]


=== Diodes and Transistors (BJT/MOSFETs) ===
A light emitting diode (LED) is a small electric light that uses low voltage and current (Figure 6). The longer lead of an LED is the anode, and the shorter lead is the cathode. The orientation of an LED is important since they are polarized. Most LEDs also require a resistor because they will burn out almost instantly when they encounter high current.


<b>Diodes</b> and <b>transistors</b> (Figure 5) allow current to only pass in one direction. MOSFETs are electrically controlled switches. They can also be used to amplify signals. They are polarized.
[[Image:Lab_LED_Proto.png |350px|thumb|center|Figure 6: An LED and its Corresponding Symbol]]
[[Image:diode_transistor.jpg|350px|thumb|center|Figure 5: Symbols for Diodes and Transistors]]


=== Light Emitting Diodes ===
A TMP36 sensor (Figure 7) uses the voltage-temperature relationship of diodes to measure temperature. The voltage across the diode of the sensor will change proportionally to the temperature. The output voltage can then be converted to a temperature reading.
<b>Light emitting diodes (LEDs)</b> are small electric lights that use low voltage and current (Figure 6). The orientation of an LED is important since it acts like a diode and only allows current to flow in one direction. Most LEDs also require a resistor (typically 470 &Omega;) in series because they will burn out almost instantly when they encounter high current. They are polarized.


[[Image:LED.jpg|center]]
[[Image:Lab_TMP36_sensor_Proto.png |200px|thumb|center|Figure 7: TMP36 Sensor]]
<center><p>Figure 6: Symbol for an LED</p></center>


== Microcontrollers ==
== Microcontrollers ==
A <b>microcontroller</b> is an inexpensive, programmable computer without any peripherals, such as a mouse, keyboard, or screen. Microcontroller boards have direct access to the input and output pins of their processing chips so that the user can directly read from sensors and perform actions. Microcontrollers are used in many electrical appliances, such as microwaves. Arduino boards (Figure 7), which use a microcontroller, were designed to be easily programmed and assembled into larger projects. These boards come in many shapes and sizes and some contain additional features, such as WiFi or Bluetooth connectivity. Different boards can also have different features, such as processing speed and memory size.
A microcontroller is an inexpensive, programmable computer without any peripherals, such as a mouse, keyboard, or screen. Microcontroller boards have direct access to the input and output pins of their processing chips so that the user can directly read from sensors and perform actions. Microcontrollers perform specific functions in household appliances, medical devices, cars, and other systems and devices. Arduino boards (Figure 8), which use a microcontroller, were designed to be easily programmed and assembled into larger projects. These boards come in many shapes and sizes, and some contain additional features, such as WiFi or Bluetooth connectivity. Different boards can also have different features, such as a higher processing speed and more memory.
 
[[Image:arduino.jpg|250px|thumb|center|Figure 8: Arduino UNO]]


[[Image:arduino.jpg|250px|thumb|center|Figure 1: Arduino UNO]]
This lab will use an Arduino UNO board created by SparkFun called a RedBoard (Figure 9).
This lab will be using an Arduino UNO board created by SparkFun called a RedBoard.  
[[Image:redboard.jpg|250px|thumb|center|Figure 2: RedBoard]]
[[Image:redboard.jpg|250px|thumb|center|Figure 9: RedBoard]]


=== Arduino Hardware ===
=== Arduino Hardware ===
[[Image:redboard_info.jpg|400px|thumb|center|Figure 3: RedBoard information]]
<b>Reset Button:</b> Restarts the Board<br/>
<b>USB Connector:</b> Provides power and connects it to the computer<br />
<b>Pin 13 LED:</b> Usable LED without making an LED circuit<br />
<b>Serial LEDS:</b> Shows if the Arduino is transmitting or receiving data from pins 0, 1 or the USB connection<br/>
[[Image:redboard_pins.jpg|150px|thumb|center|Figure 4: RedBoard pins]]
<center>Power Pins<br /></center>
<b>3.3V:</b> Usually used to power low-voltage sensors<br />
<b>5V:</b> Most common power pin used to power circuits<br />
<b>GND:</b> Ground pin which is 0V<br />
<b>VIN:</b> Voltage-In can be used to power the board using a battery<br/>
[[Image:redboard_IO.jpg|150px|thumb|center|Figure 5: RedBoard IO]]
<center>I/O Pins<br /></center>
<b>A0-A5:</b> Identical analog pins that can be used to read sensors or control analog devices. Pins A0-A3 are more stable than A4-A5.<br />
<b>Pins 0-1:</b> Transmit and Receive pins, don’t use these pins for this lab<br />
<b>Pins 2-12:</b> Digital pins that can be switched between HIGH states and LOW states<br />
<b>Pin 13:</b> Connected to the on-board LED, use it only as an input pin<br/>
=== The Arduino IDE ===
The Arduino IDE is a program that can be used to edit, compile, and upload code to a supported microcontroller. Figure 6 is a screenshot of the program:
[[Image:arduinoide.jpg|thumb|center|300px|Figure 6: Arduino IDE screenshot]]
'''''Verify''''': checks code for errors and points to where the errors occurred after it finishes. Upload: verifies code and then uploads it to the Arduino board if there are no errors. <br />
'''''Console''''': shows any errors the software found in hardware. <br />
'''''Serial Monitor''''': a tool used to see how a program is running. It’s like a multimeter for the program.
Programs written in Arduino are called sketches. A basic sketch can be broken up into 3 different areas: global, setup and loop; these areas are pictured below.
[[Image:Sketchareas.jpg‎|thumb|center|Figure 7: Different areas]]
'''''Global''''': constants and imported libraries go here.<br />
'''''Setup''''': activate the pins and sensors used. This code only runs once.<br />
'''''Loop''''': the code that runs continuously such as reading sensors and turning pins HIGH or LOW.


=== Arduino Programming ===
All Arduino boards have a general layout that is similar to that shown in Figure 10. Not all the sections and pins will be used in this lab or for the Semester Long Design Projects.
The Arduino programming language is based on C/C++, but it is designed to be simpler and easier to learn. The most intuitive way to think about programming is like building with LEGO blocks: certain rules must be followed and different building blocks can be used to build bigger parts.  
* <b>Reset Button:</b> Restarts the board
'''''General'''''
* <b>USB Connector:</b> Provides power and connects it to the computer
* Every line must either end with a semicolon ;unless it’s a conditional, loop, or function
* <b>Pin 13 LED:</b> Usable LED without making an LED circuit<br />
* Comments start with a //
* <b>Serial LEDS:</b> Shows if the Arduino is transmitting or receiving data from pins 0, 1, or the USB connection
** Comments are text that the program ignores
 
** Used to label and explain code
[[Image:redboard_info.jpg|500px|thumb|center|Figure 10: RedBoard Layout]]
'''''Datatypes'''''
 
Datatypes are the different kinds of data values that can be used, manipulated and stored using C++. The table below includes the most basic and widely used datatypes.
The <b>power pins</b> are used to supply voltage to other pins, and are also used to ground pins (Figure 11).
 
* <b>3.3V:</b> Usually used to power low-voltage sensors
* <b>5V:</b> Used to power circuits
* <b>GND:</b> Ground pin, 0V
* <b>VIN:</b> Voltage-in can be used to power the board using a battery or other external voltage source
 
[[Image:redboard_pins.jpg|150px|thumb|center|Figure 11: RedBoard Power Pins]]
 
The digital and analog pins are used for input and output commands to the microcontroller and electrical components (Figure 12). They can be used with both analog and digital devices, as the Arduino board converts analog inputs to a digital input.
 
*'''A0-A5''': Identical analog pins that can read sensors or control analog devices. Analog pins can read/write values from 0 to 1023
*'''Digital Pins 0-1''': Transmitter and receiver pins. Do not use these pins for this lab
*'''Digital Pins 2-12''': Digital pins that switch between HIGH states and LOW states. Can only read/write values HIGH or LOW, unlike analog pins that allow a greater range of values
*'''Digital Pin 13''': Connected to the onboard LED, use it only as an input pin
 
[[Image:Lab 5 Figure 11.png|200px|thumb|center|Figure 12: RedBoard Digital (I) and Analog (r) Pins]]
 
=== The Arduino IDE (Integrated Development Environment) ===
 
Arduino IDE is a program that can be used to edit, compile, and upload code to a supported microcontroller. Figure 13 shows a screenshot of the program’s interface.
 
* <b>Verify:</b> Checks code for errors and points those errors
* <b>Upload:</b> Verifies code and uploads it to the Arduino board
* <b>Console:</b> Shows errors found in the hardware
* <b>Serial Monitor:</b> Sends and receives messages to and from the board
 
[[Image:Arduino_IDE_Interface.jpeg|500px|thumb|center|Figure 13: Arduino IDE Interface ]]
 
== Arduino Programming ==
The Arduino programming language is based on C/C++, but it is designed to be simpler and easier to learn. The intuitive way to think about programming is like building with LEGO blocks: certain rules must be followed and different building blocks can be used to build bigger parts.
 
Every line must end with a semicolon (;) unless it is a conditional, loop, or function. Comments start with two backslashes (//). Comments are text that the program ignores and are used to label and explain code.
 
== Arduino Programs ==
Programs written in Arduino are called sketches. A basic sketch can be broken up into three different areas: global, setup, and loop. These areas are pictured in Figure 14.
 
* <b>Global:</b> Contains constants and imported libraries
* <b>Setup:</b> Functions that run once at the start of the program. Setup function often used to activate pins and sensors in the program
* <b>Loop:</b> Function runs continuously after Setup function. Code in a loop function will continue to run until Arduino loses power. Function often in most of the program to read sensors and switch pins HIGH or LOW
 
[[Image:Sketchareas.jpg‎|thumb|center|Figure 14: Areas in Arduino IDE Sketch]]
 
=== Data Types ===
 
<b>Data types</b> are the different kinds of data values that can be used, manipulated, and stored using C++. The most basic and widely used datatypes were shown in Table 1.
 
{| class="wikitable"
{| class="wikitable"
!Datatype!!What it stores (examples)!!Default value!!Notes
|+ Table 1: Fundamental Data Types
!Data Type!!What It Stores (Examples)!!Default Value!!Notes
|-
|-
|Boolean||style="text-align: center;"|A true value (1, TRUE, HIGH) or<br />a false value (0, FALSE, LOW)||style="text-align: center;"|0, FALSE, LOW||style="text-align: center;"|-
|<center>Boolean</center>||style="text-align: center;"|True value (1, HIGH) or<br /> false value (0, LOW)||style="text-align: center;"|0, FALSE, LOW||style="text-align: center;"|-
|-
|-
|int||style="text-align: center;"|An integer number (-5, 15, 1047, etc.)||style="text-align: center;"|0||style="text-align: center;"|Can be positive or negative
|<center>int</center>||style="text-align: center;"|Integer number (e.g. -5, 15, 1047)||style="text-align: center;"|0||style="text-align: center;"|Positive or negative
|-
|-
|double||style="text-align: center;"|A decimal number (-0.5, 123.77, etc.)||style="text-align: center;"|0||style="text-align: center;"|Can be positive or negative
|<center>double</center>||style="text-align: center;"|Decimal number (e.g. -0.5, 123.77)||style="text-align: center;"|0||style="text-align: center;"|Positive or negative
|-
|-
|char||style="text-align: center;"|A single character (‘c’, ‘A’, ‘5’, ‘?’, etc.)||style="text-align: center;"|Indeterminate||style="text-align: center;"|Must be enclosed in single quotes
|<center>char</center>||style="text-align: center;"|Single character (e.g. ‘c’, ‘A’, ‘5’, ‘?’)||style="text-align: center;"|Indeterminate||style="text-align: center;"|Enclosed in single quotes
|-
|-
|string||style="text-align: center;"|A sequence of characters (“Hello World!”,<br /> “10”, “157+5”, etc.)||style="text-align: center;"|Empty (“”)||style="text-align: center;"|Must be enclosed in double quotes
|<center>string</center>||style="text-align: center;"|Sequence of characters (e.g. “Hello World!”, “10”, “157+5”)||style="text-align: center;"|Empty (“”)||style="text-align: center;"|Enclosed in quotes
|}
|}
'''''Operators'''''
 
Operators perform operations on variables and constants. The results of these operations are usually stored in a variable. The table below includes common operators.
=== Operators ===
 
<b>Operators</b> perform operations on variables and constants. The results of these operations are usually stored in a variable. Table 2 displays common operators.
 
{| class="wikitable"
{| class="wikitable"
!Operator!!What it does!!Notes
|+ Table 2: Common Operators
!Operator!!What it Does!!Notes
|-
|-
|style="text-align: center;"|=||style="text-align: center;"|Assigns a value to a variable||style="text-align: center;"|
|style="text-align: center;"|=||style="text-align: center;"|Assigns a value to a variable||style="text-align: center;"|-
|-
|-
|style="text-align: center;"|+||style="text-align: center;"|Adds two or more values||style="text-align: center;"|
|style="text-align: center;"|+||style="text-align: center;"|Adds two or more values||style="text-align: center;"|-
|-
|-
|style="text-align: center;"|<nowiki>-</nowiki>||style="text-align: center;"|Subtracts two or more values||style="text-align: center;"|
|style="text-align: center;"|<nowiki>-</nowiki>||style="text-align: center;"|Subtracts two or more values||style="text-align: center;"|-
|-
|-
|style="text-align: center;"|*||style="text-align: center;"|Multiplies two or more values||style="text-align: center;"|
|style="text-align: center;"|*||style="text-align: center;"|Multiplies two or more values||style="text-align: center;"|-
|-
|-
|style="text-align: center;"|/||style="text-align: center;"|Divides two or more values||style="text-align: center;"|
|style="text-align: center;"|/||style="text-align: center;"|Divides two or more values||style="text-align: center;"|-
|-
|-
|style="text-align: center;"|++||style="text-align: center;"|Increment by 1||style="text-align: center;"|Usually used in loops
|style="text-align: center;"|++||style="text-align: center;"|Increment by 1||style="text-align: center;"|Usually used in loops
Line 134: Line 166:
|style="text-align: center;"|<nowiki>--</nowiki>||style="text-align: center;"|Decrement by 1||style="text-align: center;"|Usually used in loops
|style="text-align: center;"|<nowiki>--</nowiki>||style="text-align: center;"|Decrement by 1||style="text-align: center;"|Usually used in loops
|-
|-
|style="text-align: center;"|==||style="text-align: center;"|Checks if two value are equal||style="text-align: center;"|Usually used in conditionals
|style="text-align: center;"|==||style="text-align: center;"|Checks if two values are equal||style="text-align: center;"|Usually used in conditionals
|-
|-
|style="text-align: center;"|!=||style="text-align: center;"|Checks if two value are not equal||style="text-align: center;"|Usually used in conditionals
|style="text-align: center;"|!=||style="text-align: center;"|Checks if two values are not equal||style="text-align: center;"|Usually used in conditionals
|-
|-
|style="text-align: center;"|> or <||style="text-align: center;"|Less than/Greater than comparison||style="text-align: center;"|Usually used in conditionals
|style="text-align: center;"|> or <||style="text-align: center;"|Less than, greater than comparison||style="text-align: center;"|Usually used in conditionals
|-
|-
|style="text-align: center;"|<= or >=||style="text-align: center;"|Less than/greater than or equal to comparison||style="text-align: center;"|Usually used in conditionals
|style="text-align: center;"|<= or >=||style="text-align: center;"|Less than, greater than, or equal to comparison||style="text-align: center;"|Usually used in conditionals
|-
|-
|style="text-align: center;"|&& or <nowiki>||</nowiki>||style="text-align: center;"|Boolean AND or Boolean OR Used to cascade multiple Boolean operations||style="text-align: center;"|Usually used in conditionals
|style="text-align: center;"|&& or <nowiki>||</nowiki>||style="text-align: center;"|Boolean AND or Boolean OR ssed to cascade multiple Boolean operations||style="text-align: center;"|Usually used in conditionals
|-
|-
|}
|}
'''''Constants and Variables'''''
 
Constants and variables hold data according to their datatype. They need to be given a name so they can be referred to later. Constants hold data that will NOT change while a program is running. Constants usually contain pin numbers or sensor threshold values. Variables contain data that WILL change while a program is running. Variables usually contain sensor values and other values that need to have mathematical operations done on them. Below is an example of how to create different constants and variables.
=== Constants and Variables ===
[[Image:variables.png‎|thumb|center|300px|Figure 8: Constants and variables]]
 
'''''Conditional Statements'''''
<b>Constants</b> and <b>variables</b> (Figure 15) hold data according to their datatype. They must be given a name so they can be referred to later. Constants hold data that will not change while a program is running. Constants usually contain pin numbers or sensor threshold values. Variables contain data that will change while a program is running. Variables usually contain sensor values and other values that must have mathematical operations done on them. Figure 15 shows how to create different constants and variables.
Conditional statements run code enclosed by their curly brackets when a condition is met.  
 
[[Image:conditionals.jpg‎|thumb|center|400px|Figure 9: Conditional statements]]
[[Image:variables.png‎|thumb|center|336px|Figure 15: Constants and Variables]]
''Loops''
 
Loops run the code enclosed by their curly brackets a specific amount of times or until a condition is met.
=== Conditional Statements ===
''While-loop''
 
While-loops are used to perform a task until a condition is met
<b>Conditional statements</b> (Figure 16) run code enclosed by their curly brackets when a condition is met.
''For-loop''
 
For-loops are used when you want something to run a specific number of times. Although they seem complicated at first, the structure of most for-loops is the same. In the parenthesis, the first part sets a variable (usually ‘i’ for ‘index’) to a value used to begin a count, the middle is the condition when the loop stops, and the third part is where you increment or decrement the counting variable.  
[[Image:conditionals.jpg‎|thumb|center|800px|Figure 16: Conditional Statements]]
[[Image:while.jpg|thumb|center|400px|Figure 10: While and for-loops]]
 
'''''Commonly Used Arduino Functions'''''
=== Loops ===
 
Loops run the code enclosed by curly brackets for a specific number of times or until a condition is met.  
 
While loops are used to perform a task until a condition is met. In Figure 17, the while loop runs only if the state of the button is HIGH. When the state of the button becomes LOW, the while loop will stop running.
 
[[Image:Fig15lab3.png|thumb|center|500px|Figure 17: While and For Loops]]
 
=== Commonly Used Functions ===
 
Table 3 shows commonly used functions in the Arduino IDE that are specifically used to work with the digital and analog pins of the board. The digital pins on the board can input or output only two values: HIGH or LOW. While analog pins can process numerical values from 0 to 1023.
 
{| class="wikitable"
{| class="wikitable"
!Function!!What it does
|+ Table 3: Common Arduino Functions
!Function!!What it Does
|-
|-
|style="text-align: center;"|pinMode(pin,mode)||style="text-align: center;"|Sets a pin as an input or output
|style="text-align: center;"|pinMode(pin, mode)||style="text-align: center;"|Sets a pin as an input or output
|-
|-
|style="text-align: center;"|digitalWrite(pin, value)||style="text-align: center;"|Sets a digital output pin to HIGH or LOW
|style="text-align: center;"|digitalWrite(pin, value)||style="text-align: center;"|Sets a digital output pin to HIGH or LOW
|-
|-
|style="text-align: center;"|digitalRead(pin)||style="text-align: center;"|Reads an digital input pin as HIGH or LOW
|style="text-align: center;"|digitalRead(pin)||style="text-align: center;"|Reads a digital input pin as HIGH or LOW
|-
|-
|style="text-align: center;"|analogWrite(pin, value)||style="text-align: center;"|Sets an analog output pin to a value 0-1023
|style="text-align: center;"|analogWrite(pin, value)||style="text-align: center;"|Sets an analog output pin to a value 0-1023
Line 172: Line 216:
|style="text-align: center;"|analogRead(pin)||style="text-align: center;"|Reads an analog output pin as a value 0-1023
|style="text-align: center;"|analogRead(pin)||style="text-align: center;"|Reads an analog output pin as a value 0-1023
|-
|-
|style="text-align: center;"|delay(milliseconds)||style="text-align: center;"|Pauses the program for a certain amount of time
|style="text-align: center;"|delay(milliseconds)||style="text-align: center;"|Pauses program for a certain amount of time
|-
|-
|style="text-align: center;"|Serial.print(value)||style="text-align: center;"|Prints the value (variable) to the Serial Monitor.
|style="text-align: center;"|Serial.print(value)||style="text-align: center;"|Prints the value (variable) to the Serial Monitor
|}
|}


== Thermal Insulation ==
== Heat and Heat Transfer ==
<b><i>Heat </i></b>is a form of energy. <b><i>Heat transfer</i></b> is thermal energy that is transferred
from one body to another as a result of a temperature difference. <b><i>Temperature </i></b>is the measure of
the average kinetic energy of atomic motion. The faster the atoms are moving, the higher the temperature.


The specific mechanisms that convey energy from one location to another are
<b>Heat</b> is a form of energy. Heat can be beneficial, and it can be destructive. For example, the heat created by the combustion of fossil fuels in a combustion engine or the heat generated by the friction between parts of an engine in contact can destroy an engine. A heating, ventilation, and air conditioning (HVAC) system in a home keeps the home warm at cooler temperatures and cooler at higher temperatures. Many systems and devices use components and materials that are designed to remove heat from the system or retain heat in the system.
<b><i>conduction</i></b>, <b><i>convection</i></b>, and <b><i>radiation</i></b>.  
<p>When there is a temperature difference within a solid body or between two solid bodies in contact with each
other, energy (heat) will flow from the region of higher temperature to the region of lower temperature. This
is known as <b><i>conduction</i></b>.  


<p>Imagine a metal rod that is heated at one end. The atoms of the rod collide at the point where
<b>Heat transfer</b> is the process of thermal energy moving from one body to another as a result of a temperature difference. Temperature is the measure of the average kinetic energy of atomic motion. The faster the atoms are moving, the higher the temperature. The main mechanisms of heat transfer are conduction, convection, and radiation.
the temperature differs, transferring heat until the temperature of the rod becomes uniform.</p>


<p><b><i>Convection</i></b> is the transfer of heat within a fluid medium (fluids consist of gasses and liquids).
<b>Conduction</b> occurs when there is a temperature difference within a solid body or between solid bodies in contact. During conduction, energy (heat) will flow from the region of higher temperature to the region of lower temperature. Imagine a metal rod that is heated at one end. The atoms of the rod collide at the point where the temperature differs, transferring energy until the temperature of the rod becomes uniform.
Convection can occur in two different ways. Convection occurs as natural and forced convection. Forced convection occurs when the main
mechanism for heat transfer is due to the forced flow or motion of the fluid.</p>


[[Image:lab_hegg_2.jpg|frame|center|Figure 11: Air circulation diagram]]
<b>Convection</b> is the transfer of heat within a fluid medium (fluids consist of gasses and liquids). Convection can occur as natural or forced. Forced convection (Figure 19) occurs when the main mechanism for heat transfer is due to an outside force causing the fluid to move. Natural convection results from the natural difference in density between fluids, causing a liquid or gas to rise.


<p>Today we heat our homes through radiators using natural convection. Air flows through a heating element and
[[Image:lab_hegg_2.jpg|frame|center|Figure 19: Air Circulation Diagram]]
then is dispersed through the room.


<p>Suppose you wanted to disperse the heat even faster. In that case you could blow a fan past the heating
<b>Radiation</b> is the process by which energy in the form of electromagnetic radiation is emitted by a heated surface in all directions. It does not require an intervening medium to carry it. The heating of the Earth by the Sun is an example of heat transfer by radiation. Electromagnetic radiation is a means of energy transfer that occurs when an atom absorbs energy. This electromagnetic wave can propagate as heat, light, ultraviolet, or other electromagnetic waves depending on the type of atom and the amount of energy absorbed.
elements. This is forced convection; it is one of the principles used in air conditioners to have a relatively
small unit cool a large space.</p>


<p>According to the Encyclopedia Britannica, <b><i>radiation </i></b>is the process by which energy,
<b>Color</b> is a property of light. When an object appears white, it virtually reflects all the electromagnetic waves coming to it while a black object absorbs the waves. Color (reflectivity) should be considered when choosing materials for thermal insulation.
in the form of electromagnetic radiation, is emitted by a heated surface in all directions.
It does not require an intervening
medium to carry it. The heating of the Earth by the Sun is an example of heat transfer by radiation.


<p>Electromagnetic radiation is a mean of energy transfer that occurs when an atom absorbs energy. This EM wave can propagate
The container that will be built in the lab is a thermodynamic system (Figure 20), which is a part of the Universe separated from the surroundings by an imaginary boundary. There are three types of systems: open, closed, and isolated systems.
as heat, light, ultraviolet, or other electromagnetic waves depending on the type of atom and the
amount of energy absorbed.</p>


<p>Color is a property of light; when an object appears white, it virtually reflect all the EM waves coming
[[Image:lab_hegg_5.png|frame|center|Figure 20: Thermodynamic System]]
to it while a "black" object absorbs it all. Therefore, color (reflectivity) is to be considered when choosing materials for thermal
insulation. </p>


<b>Open systems</b> allow the transfer of mass and heat. For example, an open pot of boiling water is an open system. It exchanges heat and water vapor with the air around it. If collected, the water vapor can be condensed back to liquid water that has some mass.


<p>Your container is a <b>thermodynamic system</b> – a part of the Universe separated from the
<b>Closed systems</b> only allow heat to be transferred to the surroundings. A hermetically sealed bottle of soda is a closed system. If placed in a hot environment, it absorbs energy in the form of heat, but the amount of liquid within does not change.
surroundings by an imaginary boundary. There are three types of systems: open systems, closed
systems and isolated systems. </p>


[[Image:lab_hegg_5.png|frame|center|Figure 12: Thermodynamic system with a boundary.]]
<b>Isolated systems</b> do not interact with the surroundings at all. No exchange of heat or mass is possible. An ideal Thermos® is an isolated system. If hot chocolate is poured inside a Thermos, the same amount at the same temperature will be poured out later. No such system can be fabricated, but they can be approximated.


<p><b>Open systems</b> are systems where transfer of mass and heat is possible. For example, an open pot
Understanding how to minimize heat loss is the key to designing a successful insulating container. The first consideration is the materials chosen. Using materials that are poor conductors of heat, such as glass, will minimize heat loss. Plastic is also a poor conductor of heat. Foam cups are made of plastic that has tiny air bubbles suspended in it. Air is among the poorest conductors of heat. A vacuum, or the complete lack of air, is the best insulator of all. This is the principle employed in a Thermos® design.
of boiling water is an open system – it exchanges heat with the air around it and water vapor. If
collected, the water vapor can be condensed back to liquid water which has some mass.</p>


<p><b>Closed systems</b> are systems where only heat can be transferred to the surroundings. A
Another important consideration in creating the container is its cost. Minimal design uses the fewest resources while maintaining the safety and efficacy of a product.
hermetically sealed bottle of soda is a closed system. If placed in a hot environment it absorbs
energy in form of heat but the amount of liquid within does not change.</p>
 
<p><b>Isolated systems</b> are systems which do not interact with the surroundings at all. No exchange
is possible - neither heat nor mass. An ideal Thermos® is an isolated system. If hot chocolate is poured
within, you will get the same amount back at the same temperature. No such system can be fabricated but
can be approximated.</p>
 
<p>Now that we understand how heat is transferred, we must consider how to slow it down. Understanding
how to minimize heat loss is the key to designing a successful insulating container.</p>
 
<p>The first consideration is the materials you choose. Using materials that are poor conductors of heat, like glass, will minimize heat loss. </p>
 
<p>Plastic is also a poor conductor of heat. Foam cups are made of plastic which have tiny air bubbles
suspended in it. Air is among the poorest conductors of heat. A vacuum, or the
complete lack of air, is the best insulator of all. This is the principle employed in the Thermos
design.</p>
 
<p>The other important consideration in creating your container is its cost. Minimal design uses the
fewest resources while maintaining the safety and efficacy of your product.</p>
 
<p> <b><i> Thermocouples </i></b>  consist of two wires of dissimilar metals and are usually welded together or attached on a junction. When the temperature at a junction changes, it generates thermoelectric potential (emf) which is proportional to the temperature difference between the two junctions. This voltage difference can be used to measure the temperature at that junction. </p>


= Materials and Equipment =
= Materials and Equipment =
* Arduino UNO microcontroller and USB cable
* Arduino UNO microcontroller and USB cable
* Computer with Arduino IDE
* Computer with Arduino IDE
* Breadboard and jumper wire
* Breadboard
* Jumper wires
* Resistors
* Resistors
** 220 &Omega;
** 220 &Omega;
** 10 k&Omega;
** 2.2 k&Omega;
** 2.2 k&Omega;
** 10 k&Omega;
*Thermistor
* LED
* LED
* Pushbutton
* Push-button
* Thermistor
* Insulating Device Materials (Table 4)


= Procedure =
= Procedure =
<b>Starting a new sketch in Arduino</b>
# Open the Arduino IDE
# Plug the Arduino/RedBoard into the computer
# In the Arduino IDE toolbar, go to Tools > Board and select “Arduino/Genuino Uno”
# From the Tools toolbar, select the correct port
=== Building Circuits on a Breadboard ===
Breadboards are small boards that are commonly used for circuit prototyping. They allow the connection of components that were discussed previously without making permanent connections.
[[Image:breadboard.jpg|500px|thumb|center|Figure 13: Breadboard Connections]]


== Activity 1: Building an LED Circuit ==
== 1. Building an LED Circuit and Button Circuit ==
# The first activity will be making a simple LED blinking circuit. The programming flowchart and circuit diagram are in Figure 14.
#: [[Image:LED_flowchart.jpg|500px|thumb|center|Figure 14: LED Circuit Diagram and Flowchart]]
# First, wire the LED to the breadboard like in Figure 15. Remember, since LEDs are polarized, their orientation matters. The shorter leg of the LED should be connected to the same row as GND. The resistor is NECESSARY, otherwise too much current would flow and the LED will burn out! Make sure to wire power to the power (red) rail and the signal from 7 to the LED directly
#: [[Image:LED_wiring.jpg|500px|thumb|center|Figure 15: Arduino Wiring]]
# Now type the following code into a new sketch.
#: [[Image:LED_code.jpg|300px|thumb|center|Figure 16: LED Code]]
# The flowchart uses Digital Pin 7 on the Arduino as an output. Therefore, create a constant that holds the number 7 and in the setup area set Pin 7 as an output using pinMode. Then, turn the LED on by using digitalWrite, have a delay of one second, turn the LED off by using digitalWrite and then set another delay of one second.
# The LED circuit will be used in the next activity. Do not deconstruct it.


== Activity 2: Using a Button ==
# A circuit using an LED and a button will be made in Part 1. The LED should be on when the button is pressed and off when the button is not pressed. The programming flowchart and circuit diagram are shown in Figure 21.[[Image:programmingflowchart.png|400px|thumb|center|Figure 21: Programming Flowchart]][[Image:circuitdiagram.png|400px|thumb|center|Figure 22: Circuit Diagram]]
# Activity 2 adds a button to the circuit from activity 1 and requires conditionals (think if-statement). The LED should be on when the button is pressed and off when the button isn’t pressed.  
# Before breadboarding the circuit, look at the bottom side (pin side) of the button to determine which pins are connected. Note which pins are for power, ground, and digital input into the Arduino. There is a wire internally connecting the pins across the sides of the push-button (Figure 23). While the button is not pressed, pins 1 and 2 are connected, and pins 3 and 4 are connected. Make sure the button straddles the gap between the electrical contact strips on the breadboard.
# Before you breadboard the circuit look at the bottom side (pin side) of the button to examine which pins are connected.  
#: [[Image:Lab_5_Part_2_Fritz_Diagram.png|400px|thumb|center|Figure 23: Button Circuit Diagram]]
# Breadboard the circuit diagram in Figure 24. Remember, since LEDs are polarized, their orientation matters. The shorter leg of the LED should be connected to the same row as GND. The 220 Ω resistor for the LED is needed, otherwise too much current would flow and the LED will burn out. The 2.2k Ω resistor for the button is needed to get a stable input. Make sure the correct resistor is used for both the LED and the button.
#: [[Image:breadboardcircuitdiagram.png|400px|thumb|center|Figure 24: Circuit]]
# Write the Arduino program to implement the flowchart. Include comments explaining what the code is doing. The code must have comments to be approved by a TA
## First start a new sketch in the Arduino IDE
### Open the Arduino IDE
### Plug the Arduino/RedBoard into the computer
### In the Arduino IDE toolbar, go to Tools > Board > Select Arduino/Genuino Uno
### In the toolbar, go to Port and select the correct port
## In the <b>Global Area</b>, create the constants used to hold the pin numbers for the button and the LED (Figure 25).
##:[[Image:globalareacode.png|300px|thumb|center|Figure 25: Constants]]
## In the <b>Setup Area</b>, use <b>pinMode()</b> to set up the LED and Button. The LED will be set to OUTPUT since it will be controlled by the program. The button will be set to INPUT since the program will receive data from the button (Figure 26).
##:[[Image:setupareacode.png|300px|thumb|center|Figure 26: LED and Button Setup]]
## In the <b>Loop Area</b>, use <b>digitalRead()</b>, <b>digitalWrite()</b>, and a conditional to write the code that controls the button.
### Create a variable named buttonState, that will hold the input from the button (Figure 27).
###:[[Image:loopareacode1.png|200px|thumb|center|Figure 27: ButtonState Variable]]
### Use <b>digitalRead()</b> to set the buttonState variable to the current state of the button (Figure 28).
###; [[Image:loopareacode2.png|500px|thumb|center|Figure 28: DigitalRead ButtonState Variable]]
### Set up the conditional statement that will be used to control the LED. In this code, the conditional is controlled by the button state (Figure 29).
###; [[Image:conditionalstatement.png|400px|thumb|center| Figure 29: Conditional Statement]]
### Use <b>digitalWrite()</b> to control the LED. Remember, we want the LED to be on when the button is pressed, and off otherwise.
#### This line will turn the LED on (Figure 30).
####; [[Image:dw1.png|400px|thumb|center|Figure 30: LED On]]
#### This line will turn the LED off (Figure 31).
####;[[Image:dw2.png|400px|thumb|center|Figure 30: LED OFF]]


There is a line connecting the pins that are wired together internally on each side. See the schematic below, pins 1 and 2 are connected, and pins 3 and 4 are connected. Make sure the button straddles the break in the breadboard
<!--== 2. Using a Button ==
[[Image:Lab_5_Part_2_Fritz_Diagram.png|300px|thumb|center|Figure 17: Button Circuit Diagram]]
# Part 2 adds a button to the circuit from Part 1 and requires conditionals (if-statements). The LED should be on when the button is pressed and off when the button is not pressed. <b>For remote students</b>, copy the [https://www.tinkercad.com/things/ltcFAatwjUO Part 2] template to the Tinkercad workspace using the steps in Starting a New Circuit in Tinkercad.
# First, breadboard the circuit diagram in Figure 18 and sketch a flowchart of the program needed. Have a TA verify the flowchart.
# Before breadboarding the circuit, look at the bottom side (pin side) of the button to determine which pins are connected. Note which pins are for power, ground, and digital input into the Arduino.
#: [[Image:activity2.png|500px|thumb|center|Figure 18: Arduino Wiring]]
# There is a wire internally connecting the pins across the sides of the push-button (Figure 24). Pins 1 and 2 are connected, and pins 3 and 4 are connected. Make sure the button straddles the break in the breadboard.
# Write the Arduino program to implement the flowchart. Use an if statement
#: [[Image:Lab_5_Part_2_Fritz_Diagram.png|400px|thumb|center|Figure 24: Button Circuit Diagram]]
# Remember to create a constant that holds the pin number to which the button is connected and that the button will be a digital input. After the button constant, create an integer that will hold the button state:
# Breadboard the circuit diagram in Figure 25 and sketch a flowchart of the program needed. Have a TA verify the flowchart.
#: [[Image:button_read.jpg|500px|thumb|center|Figure 19: Button integer]]  
#: [[Image:Arduino_Wiring.png|600px|thumb|center|Figure 25: Part 2 Wiring]]
# Within the loop function, you must check the state of the button (whether it is pressed or not pressed), using the following code:
# Write the Arduino program to implement the flowchart. Use an if-statement. Refer to the Conditional Statements part of the Overview for help with writing if-statements.
#: [[Image:button_state.jpg|300px|thumb|center|Figure 20: Button state]]
# Remember to create a constant that holds the pin number that the button is connected to and that the button will be a digital input. After the button constant, create an integer that will hold the button state, as shown in Figure 26.
#: [[Image:button_read.jpg|600px|thumb|center|Figure 26: Button Integer]]  
# Within the loop function, check the state of the button (whether it is pressed or not pressed), using the code in Figure 27.
#: [[Image:button_state.jpg|400px|thumb|center|Figure 27: Button State]]
# Take screenshots or pictures of the final code, circuit, and results (the LED state when the button is pressed and is not pressed), and send the files to yourself.-->
 
== 2. Prototyping a Thermal Insulation Device ==


== Activity 3: Prototyping a Thermal Insulation Device and Product Evaluation ==
=== Competition Rules ===
=== Competition Rules ===


The following rules must be observed at all times during
The following rules must be observed at all times during the competition. Violation of any of these rules will result in disqualification.
the competition. Violation of any of these rules will result in the
disqualification.


* You must use a cup or clay in the design of your thermal insulation device
* The placement of the thermistor with respect to the lid may not be changed
* In order to protect the wax from being ruined, no materials may be poured on top of the jar
* The thermal insulating device may not be held while testing
* Students are not allowed change the placement of the thermistor with respect to the lid
* The container may not be held
* External heat sources are prohibited
* External heat sources are prohibited
* The candle must be inside the container within 30 seconds from when you receive it
* The jar of beeswax must be inside the container within 30 seconds of it being received
* The jar of beeswax cannot be returned (no restarts)
* A minimum of $0.40 must be used in the design of the insulating device
The competition will be judged by the minimal design ratio (MDR) (2) of the design. The design with the lowest MDR wins
<center><math>MDR = \left | IC \right | \times Cost \times \frac{T_{\text{R}}}{T_{\text{F}}}\,</math></center>
<p style="text-align:right">(2)</p>


=== Materials with Price List ===
In (2), <b>IC</b> is the insulating capacity, <b>Cost</b> is the cost of the container, <b>T<sub>R</sub></b> is the temperature of the room, and <b>T<sub>F</sub> </b> is the final temperature read by the thermistor. Ask a TA for the room temperature
* Large foam cup - $0.50
* Lid - $0.25
* Pack of clay - $0.20/bag
* Wool fabric pieces - $0.10/2 pieces
* Cotton balls - $0.05/3 pieces
* Popsicle sticks - $0.01/stick
* Paper cup - $0.40
* Styrofoam pieces - $0.05/3 pieces
* Tape - $0.10/ft
* Aluminum foil - $0.30/ft<SUP>2</SUP>
* Plastic wrap - $0.02/ft<SUP>2</SUP>


The insulating container will be built using the materials in Table 4. Select the materials carefully. Consider their cost and their use as an insulator. Review the competition ratio before purchasing materials


<b><font color=#ff0000>"NO RETURN" POLICY</font>: When calculating cost, you must include
{| class="wikitable"
ALL materials you request, even if you end up not using them. Make your selections carefully so you don't end up with cost that hurts your performance, but has no benefit.</b>
|+ Table 4: Materials and Costs
!Material!!Unit!!Cost Per Unit
|-
|style="text-align: center;"|Large foam cup||style="text-align: center;"|1||style="text-align: center;"|$0.50
|-
|style="text-align: center;"|Pack of clay||style="text-align: center;"|1 bag||style="text-align: center;"|$0.20
|-
|style="text-align: center;"|Wool fabric||style="text-align: center;"|2 pieces||style="text-align: center;"|$0.10
|-
|style="text-align: center;"|Cotton balls||style="text-align: center;"|3 balls||style="text-align: center;"|$0.05
|-
|style="text-align: center;"|Popsicle sticks||style="text-align: center;"|1||style="text-align: center;"|$0.01
|-
|style="text-align: center;"|Paper cup||style="text-align: center;"|1||style="text-align: center;"|$0.40
|-
|style="text-align: center;"|Styrofoam pieces||style="text-align: center;"|5||style="text-align: center;"|$0.05
|-
|style="text-align: center;"|Tape||style="text-align: center;"|1 ft||style="text-align: center;"|$0.10
|-
|style="text-align: center;"|Aluminum foil||style="text-align: center;"|1 ft<sup>2</sup>||style="text-align: center;"|$0.30
|-
|style="text-align: center;"|Plastic wrap||style="text-align: center;"|1 ft<sup>2</sup>||style="text-align: center;"|$0.02
|-
|}


=== Competition Procedure ===
<b><font color=#ff0000>NO RETURN POLICY</font>: When calculating cost, ALL materials requested must be included, even if they were not used. Choose the materials carefully to avoid increasing the cost unnecessarily.</b>
====Building a Thermistor====
<ol>
Using the Arduino, the temperature change of the candle will be recorded over the course of 15 minutes. The Arduino will read the temperature through the thermistor and print out the values into serial monitor.
[[Image:ArduinoConnection.png|thumb|center|500px|Figure 21: Arduino thermistor wiring diagram.]]
<li>Carefully remove the existing circuit, and wire the circuit according to the following configuration. A 10 K&Omega; (Brown, Black, Orange) resistor should be used. Make sure that pin A0 is used, and the circuit is powered to 5V and grounded. </li>
<li> Download the program here: https://drive.google.com/open?id=1XTx0EHq4knP3qQIawumjvxLWdxH4rp1T
</li>There are missing components in the code; make sure to read through the comments and insert code where it is necessary.
</li>After the program is completed and uploaded, open up the Serial Monitor to check if the readings are correct (should be in the 70s &deg;F range).
Keep the circuit intact since it will be used to measure the temperature of your container.
</li>


<li>Notes:
== 3. Competition Procedure ==
A thermistor is a thermal resistor, which is a resistor that changes resistance with temperature. Depending on the temperature that it detects, the amount of voltage that goes through the thermistor will change proportionally to the temperature. Using the output voltage of the thermistor, it can be converted to a temperature reading.
The Arduino should be taking a temperature reading every 5 seconds. The analog voltage value read through pin A0 should then be converted to a Fahrenheit reading. The temperature reading should be printed to the Serial monitor along with the seconds timestamp of the reading.</li>


=== Building a Thermistor ===


</ol>
Using the Arduino, the temperature change of the hot wax will be recorded over 10 minutes. The Arduino will read the temperature through the thermistor and print the values into the serial monitor.


==== Insulating Container Design ====
#Carefully remove the existing circuit and wire the circuit according to the configuration in Figure 32. A <b>10 k&Omega;</b> (If four-banded, Brown, Black, Orange, and Gold). If five-banded, (Brown, Black, Black, Red, and Gold) resistor should be used. Make sure that pin A0 is used, and the circuit is powered to 5V and grounded. [[Image:ArduinoConnection.png|thumb|center|600px|Figure 32: Arduino Thermistor Wiring Diagram]]
<ol>
#Download the [[Media:Lab3.zip | Arduino Program]] to be used to operate the thermistor.
<li>Analyze your materials and consider your design options, keeping in mind the lab's specifications.
#There are missing components in the code. Read through the comments and insert code where necessary. After the program is completed and uploaded, open the <b>Serial Monitor</b> to check if the readings are correct (should be at or near 70 &deg;F). Keep the circuit intact since it will be used to measure the temperature of the wax.
Make sure you make preliminary sketches during this process.</li>
#The Arduino should be taking a temperature reading every 15 sec. The analog voltage value read through pin A0 should then be converted to degrees Fahrenheit. The temperature reading should be printed to the Serial Monitor along with the seconds timestamp of the reading.
<li>Now, sketch your design. Label your drawings clearly. Prepare a price-list
for your insulating container based on the materials you have chosen. </li>
<li>Build your insulating container based on the sketch you just completed. Your TA will provide the
materials needed for your design. If you decide to modify your design during the construction of your
insulating container, note the changes and describe the reasons for them. If the modifications required
more materials to be used, make sure you update your price list and your TA approves it.</li>
</ol>


=== Insulating Device Design ===


#Analyze the materials and consider the design options, keeping in mind the lab's specifications. Make preliminary sketches during this process.
#Sketch the design. Label the drawings clearly. Prepare a price list and write down the total cost for the insulating container based on the materials chosen. Receive approval of the design sketch from a TA.
#Build the insulating device based on the completed sketch. The TA will provide the materials needed for the design. If the design is modified during construction, note the changes and describe the reasons for them. If the modifications required more materials, update the price list and obtain approval. <span style="color: red;"> a reminder, materials that are purchased but ultimately to not end up in the final design are still counted towards the final cost of the device.</span>


==== Competition ====
=== Competition ===


<ol>
# Have a TA verify the fixed Arduino code. Run the program for approximately 30 sec to obtain an average room temperature. The data from the Arduino can be seen in the Serial Monitor on the top right corner of the Arduino IDE.
<li>Have a TA test your Arduino code. Run the program for approximately 30 seconds to obtain an average room temperature. The data from the Arduino can be seen in the Serial Monitor on the top right corner of the Arduino IDE.</li>
# Stop the program after 30 sec and check to ensure that the data was collected. Record the average room temperature provided by the TAs.
<li> Stop the program after 30 seconds and check to ensure that the data was collected. </li>
# The TA will bring the heated wax. Place the lid with the thermistor attached over the top of the wax. Be sure the top of the container is loosely covered with the lid.
<li>The TA will bring the candle to you once you are ready to receive it. Place the lid with the thermistor attached over the top of the wax. Be sure the top of the container is loosely covered with the lid. </li>
# Do not adjust the thermistor from its position in the lid. Do not screw on the lid, just place it over the container. <span style="color: red;">Warning: Be careful! The melted wax is hot!</span>
<li>Do not adjust the thermistor from its position in the lid.</li>
# Restart the Arduino program. Once the temperature readings stop increasing, start timing the 10 minute run.
<li>Do not screw on the lid; just place it over the container.</li>
# The data from the thermistor will allow for further analysis. The Arduino data from the Serial Monitor will be used to calculate the insulating capacity (IC) for the competition ratio. <span style="color: red;">DO NOT CLOSE OUT OF THE SERIAL MONITOR WINDOW.</span> This will reset and erase all data previously displayed. There is no way to recover erased serial monitor data. After 10 min from the time the temperature readings stop increasing, copy and paste the data from the Serial Monitor into a Microsoft Excel file.


<span style="color: red;"> Warning: Be careful! The hot melted wax is HOT! </span>
== 4. Data Analysis ==


<li>Restart your Arduino program. Once the temperature readings stop increasing, start timing your 15 minute run. </li>
# The data pasted from the Serial Monitor into Excel is not correctly separated into columns. To present the data in the correct format, highlight all the data, and go to the <b>Data tab</b> and select <b>“Text to Columns”</b> (Figure 33).
<li> The data from the thermistor will allow for further analysis.
#:[[Image:datatab.png|700px|center|Figure 33: Text to Columns]]
<span style="color: red;"> The Arduino data from the Serial Monitor will be used to attain the IC for the competition calculation. PLEASE DO NOT CLOSE OUT OF THE SERIAL MONITOR WINDOW. After 15 minutes (or 900 seconds), copy the data from the serial monitor into an Excel file. </span></ol>
# In the <b>Text-to-Columns</b> wizard, select <b>Delimited</b> as the data type and click <b>Next</b>. Then select <b>“Comma”</b> as the delimiter, and hit <b>“Finish”</b>. Ensure that the data has been separated into two separate columns. 
# Create a graph of the data using the X, Y Scatter template. First, select the data starting from where the temperature readings stops increasing (example below). Next go to the <b>Insert</b> tab, and click on the first <b>Scatter</b> option under the <b>Charts</b> group. This should create a new scatter plot, as shown in Figure 34.
#:[[Image:charts.png|400px|center|Figure 34: Scatter plot]]
# Next add axis labels and a trendline. First click on the graph, and then the green <b>“+”</b> icon next to it. Then, check off <b>“Axis Titles, Chart Titles, and Trendline”</b>. Click on the added labels to edit the text.  When finished, the graph should look similar to Figure 35.
#:[[Image:charttitle.png|400px|center|Figure 35: Temperature vs. Time Graph of the Thermal Insulation Device]]
# Calculate the insulating capacity (IC) of the design. This will be done using the trendline equation. Right-click on the trendline and select <b>“Format Trendline”</b>. On the <b>“Trendline Options”</b> tab, ensure that the trendline is linear. Select the <b>“Display Equation on Chart"</b> option. The slope of this linear equation is the IC.
# Give the IC, final temperature, and total cost to the TA to enter the design's performance into the competition score sheet and calculate the MDR.


==== Data Analysis ====
The lab work is now complete. Please clean up the workstation. Return all unused materials to a TA.


<ol>
= Assignment =
<li>
The data pasted from the Serial Monitor into Excel is not correctly separated into columns; therefore, to put them in the correct format, highlight all the data, and go to Data -> Text to Columns -> Delimited, and check off comma. Press finish to see the data in the correct columns.
</li>
<li>Create a graph using the X, Y Scatter template.


You'll find the template on the <b><i>Insert</i></b> tab, under the
Note: <b>Part 2: Thermal Insulation Device Competition</b> will be included in both lab report and team presentation. <b>Part 1: Building an LED and Button Circuit</b> DOES NOT need to be included in the lab report and team presentation.  
<b><i>Charts</i></b> group, with the <b><i>Scatter</i></b> icon. Click
on the arrow below the icon and select the top left icon in the pulldown
gallery. You can get the axes you want by clicking on the axis. You can get
labels and titles by clicking on the chart, which will change the ribbon to the
<b><i>Design</i></b> tab. In the <b><i>Charts Layout</i></b> group, click the
icon that looks like the chart you want. Right click on the things you want to
change.</li>
<li>For the thermistor name the X-axis <i>Time</i>, name the Y-axis <i>Temperature</i>. Plot it in half minute intervals for fifteen minutes, starting from the downhill trend. You may need to divide the Arduino data by 60 to convert to minutes. You may select the intervals based on your results. When you are finished, your graph should look similar to Figure 22.</li>
 
[[Image:Lab_hegg_7.PNG|frame|center|Figure 22: Temperature vs. Time diagram of first 15 minutes of VI run]]
 
<li>Calculate the <b><i>Insulating Capacity (IC) </i></b>of your design, do not include the first few seconds of an uphill trend, this is just the thermistor changing from room temperature to the temperature of the wax. <b><i>IC</i></b>
The IC is the value of the slope of the graph of fifteen minutes of data. <span style="color: red;">  The IC is calculated using the data from the Arduino for this lab. </span></li>
 
<li>Add a trendline to your graph. To do so, click on the chart to get the <b><i>Design</i></b> tab on the
ribbon. Under the <b><i>Chart Layouts</i></b> group, click on the chart
template that has a trend line. As before, right click on the various items to
make them what you want, including deleting things. Finally, right click on the
trend line. This will bring up the <b><i>Format Trendline</i></b> window. On
the left side, the <b><i>Trendline Options</i></b> item should be highlighted.
If it isn't, click on it to highlight it. On the right side near the bottom is
an item <b><i>Display Equation on chart</i></b>. Click on the check box to the
left of this item and click <b><i>Close</i></b>. You can then click on the
equation that's on the chart to move it where you want.</li>
<li>Calculate the <b><i>Minimal Design Ratio (MDR)</i></b> for your design:</li>
 
<math>MDR = \left | IC \right | \times cost \times \frac{T_{\text{R}}}{T_{\text{F}}}\,</math>
 
<b>IC</b> is the insulating capacity you calculated earlier. <b>Cost</b> is the cost of your container, <b>T<sub>R</sub></b> is the temperature of the room given to you by the TA, and <b>T<sub>F</sub></b> is the final temperature read by the
thermistor. Check the MDR using data from all the devices for a better reference. '''Again, please use IC from Arduino to calculate the final MDR.'''
</ol>
 
'''Note: If your average room temperature is significantly different from the TA's average, let the TA know.'''
 
The team with the <b><i>lowest MDR</i></b> wins.
 
Your lab work is now complete. Please clean up your workstation. Return all
unused materials to your TA.
 
= Assignment =


== Individual Lab Report ==
== Individual Lab Report ==
<!--
<!--
* For EG1003: This is a REQUIRED Lab Report
* For EG1004: This is a REQUIRED Lab Report
*
*
-->
-->
{{Labs:Lab Report}} The LED and button circuit procedure does not need to be discussed.


Follow the lab report guidelines laid out in the page called
*Abstract
[[Specifications for Writing Your Lab Reports]] in the <i>Technical Communication</i> section of this
**Briefly summarize the lab exercise. Include the competition results
manual. As you write, the following discussion points should be addressed in the appropriate section of your lab report:
*Introduction
 
**Discuss prototyping, the hardware and software components used in the lab, heat and heat transfer,  all elements of the competition, and the design strategy and impact of rules, materials, and ratio on design strategy
<ul>
*Procedure
 
**Materials
<li>Describe the basics of Arduino and its application</li>
**Describe the steps taken in the competition exercise in sufficient detail so that another person could follow the description and replicate the results
<li>Explain heat, heat transfer and all the mechanisms that perform heat transfer. Discuss which of these mechanisms applied to your design</li>
*Data/Observations 
<li>Define what thermal insulation is and the different types of thermodynamic systems</li>
**Present and discuss all data collected during the exercise
<li>Discuss minimal design and its importance</li>
*Conclusion
<li>Describe your container's design. Explain the choices you made. Make sure you include a
**Analyze the competition results using the data from the competition
discussion of the materials you chose and why. Talk about your team's strategy
**Describe how the design’s performance could be improved. Recalculate the ratio to prove that design modifications would improve performance
for winning the competition</li>
** Discuss what factors could affect the MDR and IC
<li>What changes would have increased/decreased your MDR or IC?</li>
**Describe the Temperature vs Time graph. Discuss potential factors that could affect the graph readings that were recorded and the shape of the graph       
<li>How did your team derive the IC value?
*Contribution Statement


<li>Should the <b><i>Temperature vs. Time </i></b>graph be smooth or should it have spikes?
Explain how closely your curve approximates the ideal and what would affect the readings you recorded</li>


<li>Describe how your design succeeded or failed. Discuss design improvements</li>
Note: It is not unusual to experience instrumentation errors in this lab, leading to incorrect temperatures being recorded. Be sure to read [[How to Handle Unusual Data]] in the manual to learn how to handle this.


<li>Include spreadsheet with every team's results. Describe the results and talk about other designs in the class
{{Labs:Lab Notes}}
 
</ul>
 
<b>Note:</b> It is not unusual to experience instrumentation errors in this lab, leading to
incorrect temperatures being recorded. Be sure to read [[How to Handle Unusual Data]] in the
online manual to learn how to handle this.
 
{{Lab notes}}


== Team PowerPoint Presentation ==
== Team PowerPoint Presentation ==


Follow the presentation guidelines laid out in the page called
{{Labs:Team Presentation}}
[[EG1003 Lab Presentation Format]] in the <i>Introduction to Technical Presentations</i>
section of this manual. When you are preparing your presentation, consider the following
points:
 
<ul>
<li>What is the importance of prototyping and using Arduino?</li>
<li>What is the importance of minimal design?</li>
<li>What is the importance of materials in prototyping?</li>
<li>Why is it important in today's world to minimize heat loss?</li>
<li>What is the importance of proper data collection method and automation?</li>
<li> Is there any benefit to using one data collection method over the other? </li>
<li>How would you improve your design?</li>
</ul>


*What is the importance of prototyping and using Arduino?
*What is the importance of minimal design?
*How are materials selected in prototyping?
*Why is it important to minimize heat loss?
*What is the importance of the automation of proper data collection methods?
*How can the design be improved?


= References =
Poff, Zach. (n.d.). “Resistor Color Code Chart.” Accessed August 11, 2021 from zachpoff.com


[[Main_Page | Return to Table of Contents]]'''
{{Laboratory Experiments}}

Revision as of 21:48, 9 February 2023

Objective

This is a competition lab that will require designing an effective thermal insulation device. An Arduino board and other electronic components will be used to design the device. Data analysis will be performed to see if the device slowed the rate of heat loss from a container of melted wax placed inside it. The performance of the device will be rated by a design ratio that uses the cost of the device, insulating capacity, the final temperature of the melted wax, and the room temperature. The lowest ratio wins the competition.

Overview

Prototyping

Prototyping is the process of designing and building an early model of a product to test it. Any system or device that will be sold to consumers, government agencies, or businesses will begin as a prototype that typically does not have all of the components or functions that will be used in the final product that is brought to market. A prototype can serve as a proof of concept showing that the system or device can be built and will perform correctly.

In this lab, a prototype of a thermal insulation device will be built. Its function will be to reduce the rate of heat loss from a container of heated wax that will be placed in the device. The prototype insulating device will use a TMP 36 sensor to measure heat loss and it will be operated by a microcontroller.

Electricity

Electricity is the movement of electrons. Electrons flow through a conductive wire when there is a difference in charge between two points in the wire. This flow of electrons is the electrical current and it is measured in amperes (A). Electrical current flows in the opposite direction of the electrons. The difference in charge is the electrical voltage and is measured in volts (V). Certain materials resist the flow of electrons. This property is electrical resistance and is measured in ohms (Ω).

Ohm’s Law (1) describes the relationship of the voltage across a resistor, the current (I) flowing through a resistor, and the resistance (R) of the resistor.

(1)

Variations in voltage and current are used in digital signal processing to operate complex systems and devices and simpler devices, such as microcontrollers and household digital instruments.

Electrical Components

Several basic electrical components are used to build simple circuits.

Breadboards

Breadboards (Figure 1) are small boards that are commonly used for circuit prototyping. They allow the circuit’s components to be connected without making permanent connections. The red and blue strips on the sides of the board (sections A and D) are called power rails and are connected down the board, usually used for powering and grounding. The non-colored rows between the power and ground strips (sections B and C) are connected across and are usually used for making the connections between components. Sections B and C are not connected to each other across the bridge in the middle of the board.

Figure 1: Breadboard Connections

DC (Direct Current) Voltage Sources

DC voltage sources are used to power circuits because they have a voltage difference across their terminals. DC voltage sources are usually batteries (e.g. AA, AAA). Arduino boards can be powered by a battery, a USB cable, or an AC adapter. When the Arduino is powered, it can be used as a 5V DC voltage source.

Resistors

Resistors (Figure 2) are components that reduce the current flowing through a circuit and convert the excess current into thermal energy. They are one of the most common components in electrical circuits. Resistors are mainly used to limit the current flowing through a component. For example, when connecting an LED to a battery, a resistor helps limit the circuit to ensure the LED is not damaged.

Figure 2: Resistor (I) & Resistor Symbol (r) used in Circuit Diagrams

Resistors are color coded to indicate their resistance in ohms (Figure 3). They are not polarized, meaning the orientation of the resistor does not affect the circuit.

Figure 3: Resistor Color Codes (zachpoff.com)

Push-Buttons and Switches

Push-buttons and switches (Figure 4) are mechanical devices that interrupt or divert current. Basic push-buttons are polarized while basic switches are not.

Figure 4: A Push Button, and its Internal Switch Circuit

Diodes

Diodes allow current to pass in only one direction. The anode is the positive terminal of the diode, and the cathode is the negative terminal. Diodes can also be used to amplify signals (Figure 5).

Figure 5: A Diode and its Corresponding Symbol

A light emitting diode (LED) is a small electric light that uses low voltage and current (Figure 6). The longer lead of an LED is the anode, and the shorter lead is the cathode. The orientation of an LED is important since they are polarized. Most LEDs also require a resistor because they will burn out almost instantly when they encounter high current.

Figure 6: An LED and its Corresponding Symbol

A TMP36 sensor (Figure 7) uses the voltage-temperature relationship of diodes to measure temperature. The voltage across the diode of the sensor will change proportionally to the temperature. The output voltage can then be converted to a temperature reading.

Figure 7: TMP36 Sensor

Microcontrollers

A microcontroller is an inexpensive, programmable computer without any peripherals, such as a mouse, keyboard, or screen. Microcontroller boards have direct access to the input and output pins of their processing chips so that the user can directly read from sensors and perform actions. Microcontrollers perform specific functions in household appliances, medical devices, cars, and other systems and devices. Arduino boards (Figure 8), which use a microcontroller, were designed to be easily programmed and assembled into larger projects. These boards come in many shapes and sizes, and some contain additional features, such as WiFi or Bluetooth connectivity. Different boards can also have different features, such as a higher processing speed and more memory.

Figure 8: Arduino UNO

This lab will use an Arduino UNO board created by SparkFun called a RedBoard (Figure 9).

Figure 9: RedBoard

Arduino Hardware

All Arduino boards have a general layout that is similar to that shown in Figure 10. Not all the sections and pins will be used in this lab or for the Semester Long Design Projects.

  • Reset Button: Restarts the board
  • USB Connector: Provides power and connects it to the computer
  • Pin 13 LED: Usable LED without making an LED circuit
  • Serial LEDS: Shows if the Arduino is transmitting or receiving data from pins 0, 1, or the USB connection
Figure 10: RedBoard Layout

The power pins are used to supply voltage to other pins, and are also used to ground pins (Figure 11).

  • 3.3V: Usually used to power low-voltage sensors
  • 5V: Used to power circuits
  • GND: Ground pin, 0V
  • VIN: Voltage-in can be used to power the board using a battery or other external voltage source
Figure 11: RedBoard Power Pins

The digital and analog pins are used for input and output commands to the microcontroller and electrical components (Figure 12). They can be used with both analog and digital devices, as the Arduino board converts analog inputs to a digital input.

  • A0-A5: Identical analog pins that can read sensors or control analog devices. Analog pins can read/write values from 0 to 1023
  • Digital Pins 0-1: Transmitter and receiver pins. Do not use these pins for this lab
  • Digital Pins 2-12: Digital pins that switch between HIGH states and LOW states. Can only read/write values HIGH or LOW, unlike analog pins that allow a greater range of values
  • Digital Pin 13: Connected to the onboard LED, use it only as an input pin
Figure 12: RedBoard Digital (I) and Analog (r) Pins

The Arduino IDE (Integrated Development Environment)

Arduino IDE is a program that can be used to edit, compile, and upload code to a supported microcontroller. Figure 13 shows a screenshot of the program’s interface.

  • Verify: Checks code for errors and points those errors
  • Upload: Verifies code and uploads it to the Arduino board
  • Console: Shows errors found in the hardware
  • Serial Monitor: Sends and receives messages to and from the board
Figure 13: Arduino IDE Interface

Arduino Programming

The Arduino programming language is based on C/C++, but it is designed to be simpler and easier to learn. The intuitive way to think about programming is like building with LEGO blocks: certain rules must be followed and different building blocks can be used to build bigger parts.

Every line must end with a semicolon (;) unless it is a conditional, loop, or function. Comments start with two backslashes (//). Comments are text that the program ignores and are used to label and explain code.

Arduino Programs

Programs written in Arduino are called sketches. A basic sketch can be broken up into three different areas: global, setup, and loop. These areas are pictured in Figure 14.

  • Global: Contains constants and imported libraries
  • Setup: Functions that run once at the start of the program. Setup function often used to activate pins and sensors in the program
  • Loop: Function runs continuously after Setup function. Code in a loop function will continue to run until Arduino loses power. Function often in most of the program to read sensors and switch pins HIGH or LOW
Figure 14: Areas in Arduino IDE Sketch

Data Types

Data types are the different kinds of data values that can be used, manipulated, and stored using C++. The most basic and widely used datatypes were shown in Table 1.

Table 1: Fundamental Data Types
Data Type What It Stores (Examples) Default Value Notes
Boolean
True value (1, HIGH) or
false value (0, LOW)
0, FALSE, LOW -
int
Integer number (e.g. -5, 15, 1047) 0 Positive or negative
double
Decimal number (e.g. -0.5, 123.77) 0 Positive or negative
char
Single character (e.g. ‘c’, ‘A’, ‘5’, ‘?’) Indeterminate Enclosed in single quotes
string
Sequence of characters (e.g. “Hello World!”, “10”, “157+5”) Empty (“”) Enclosed in quotes

Operators

Operators perform operations on variables and constants. The results of these operations are usually stored in a variable. Table 2 displays common operators.

Table 2: Common Operators
Operator What it Does Notes
= Assigns a value to a variable -
+ Adds two or more values -
- Subtracts two or more values -
* Multiplies two or more values -
/ Divides two or more values -
++ Increment by 1 Usually used in loops
-- Decrement by 1 Usually used in loops
== Checks if two values are equal Usually used in conditionals
!= Checks if two values are not equal Usually used in conditionals
> or < Less than, greater than comparison Usually used in conditionals
<= or >= Less than, greater than, or equal to comparison Usually used in conditionals
&& or || Boolean AND or Boolean OR ssed to cascade multiple Boolean operations Usually used in conditionals

Constants and Variables

Constants and variables (Figure 15) hold data according to their datatype. They must be given a name so they can be referred to later. Constants hold data that will not change while a program is running. Constants usually contain pin numbers or sensor threshold values. Variables contain data that will change while a program is running. Variables usually contain sensor values and other values that must have mathematical operations done on them. Figure 15 shows how to create different constants and variables.

Figure 15: Constants and Variables

Conditional Statements

Conditional statements (Figure 16) run code enclosed by their curly brackets when a condition is met.

Figure 16: Conditional Statements

Loops

Loops run the code enclosed by curly brackets for a specific number of times or until a condition is met.

While loops are used to perform a task until a condition is met. In Figure 17, the while loop runs only if the state of the button is HIGH. When the state of the button becomes LOW, the while loop will stop running.

Figure 17: While and For Loops

Commonly Used Functions

Table 3 shows commonly used functions in the Arduino IDE that are specifically used to work with the digital and analog pins of the board. The digital pins on the board can input or output only two values: HIGH or LOW. While analog pins can process numerical values from 0 to 1023.

Table 3: Common Arduino Functions
Function What it Does
pinMode(pin, mode) Sets a pin as an input or output
digitalWrite(pin, value) Sets a digital output pin to HIGH or LOW
digitalRead(pin) Reads a digital input pin as HIGH or LOW
analogWrite(pin, value) Sets an analog output pin to a value 0-1023
analogRead(pin) Reads an analog output pin as a value 0-1023
delay(milliseconds) Pauses program for a certain amount of time
Serial.print(value) Prints the value (variable) to the Serial Monitor

Heat and Heat Transfer

Heat is a form of energy. Heat can be beneficial, and it can be destructive. For example, the heat created by the combustion of fossil fuels in a combustion engine or the heat generated by the friction between parts of an engine in contact can destroy an engine. A heating, ventilation, and air conditioning (HVAC) system in a home keeps the home warm at cooler temperatures and cooler at higher temperatures. Many systems and devices use components and materials that are designed to remove heat from the system or retain heat in the system.

Heat transfer is the process of thermal energy moving from one body to another as a result of a temperature difference. Temperature is the measure of the average kinetic energy of atomic motion. The faster the atoms are moving, the higher the temperature. The main mechanisms of heat transfer are conduction, convection, and radiation.

Conduction occurs when there is a temperature difference within a solid body or between solid bodies in contact. During conduction, energy (heat) will flow from the region of higher temperature to the region of lower temperature. Imagine a metal rod that is heated at one end. The atoms of the rod collide at the point where the temperature differs, transferring energy until the temperature of the rod becomes uniform.

Convection is the transfer of heat within a fluid medium (fluids consist of gasses and liquids). Convection can occur as natural or forced. Forced convection (Figure 19) occurs when the main mechanism for heat transfer is due to an outside force causing the fluid to move. Natural convection results from the natural difference in density between fluids, causing a liquid or gas to rise.

Figure 19: Air Circulation Diagram

Radiation is the process by which energy in the form of electromagnetic radiation is emitted by a heated surface in all directions. It does not require an intervening medium to carry it. The heating of the Earth by the Sun is an example of heat transfer by radiation. Electromagnetic radiation is a means of energy transfer that occurs when an atom absorbs energy. This electromagnetic wave can propagate as heat, light, ultraviolet, or other electromagnetic waves depending on the type of atom and the amount of energy absorbed.

Color is a property of light. When an object appears white, it virtually reflects all the electromagnetic waves coming to it while a black object absorbs the waves. Color (reflectivity) should be considered when choosing materials for thermal insulation.

The container that will be built in the lab is a thermodynamic system (Figure 20), which is a part of the Universe separated from the surroundings by an imaginary boundary. There are three types of systems: open, closed, and isolated systems.

Figure 20: Thermodynamic System

Open systems allow the transfer of mass and heat. For example, an open pot of boiling water is an open system. It exchanges heat and water vapor with the air around it. If collected, the water vapor can be condensed back to liquid water that has some mass.

Closed systems only allow heat to be transferred to the surroundings. A hermetically sealed bottle of soda is a closed system. If placed in a hot environment, it absorbs energy in the form of heat, but the amount of liquid within does not change.

Isolated systems do not interact with the surroundings at all. No exchange of heat or mass is possible. An ideal Thermos® is an isolated system. If hot chocolate is poured inside a Thermos, the same amount at the same temperature will be poured out later. No such system can be fabricated, but they can be approximated.

Understanding how to minimize heat loss is the key to designing a successful insulating container. The first consideration is the materials chosen. Using materials that are poor conductors of heat, such as glass, will minimize heat loss. Plastic is also a poor conductor of heat. Foam cups are made of plastic that has tiny air bubbles suspended in it. Air is among the poorest conductors of heat. A vacuum, or the complete lack of air, is the best insulator of all. This is the principle employed in a Thermos® design.

Another important consideration in creating the container is its cost. Minimal design uses the fewest resources while maintaining the safety and efficacy of a product.

Materials and Equipment

  • Arduino UNO microcontroller and USB cable
  • Computer with Arduino IDE
  • Breadboard
  • Jumper wires
  • Resistors
    • 220 Ω
    • 10 kΩ
    • 2.2 kΩ
  • LED
  • Push-button
  • Thermistor
  • Insulating Device Materials (Table 4)

Procedure

1. Building an LED Circuit and Button Circuit

  1. A circuit using an LED and a button will be made in Part 1. The LED should be on when the button is pressed and off when the button is not pressed. The programming flowchart and circuit diagram are shown in Figure 21.
    Figure 21: Programming Flowchart
    Figure 22: Circuit Diagram
  2. Before breadboarding the circuit, look at the bottom side (pin side) of the button to determine which pins are connected. Note which pins are for power, ground, and digital input into the Arduino. There is a wire internally connecting the pins across the sides of the push-button (Figure 23). While the button is not pressed, pins 1 and 2 are connected, and pins 3 and 4 are connected. Make sure the button straddles the gap between the electrical contact strips on the breadboard.
    Figure 23: Button Circuit Diagram
  3. Breadboard the circuit diagram in Figure 24. Remember, since LEDs are polarized, their orientation matters. The shorter leg of the LED should be connected to the same row as GND. The 220 Ω resistor for the LED is needed, otherwise too much current would flow and the LED will burn out. The 2.2k Ω resistor for the button is needed to get a stable input. Make sure the correct resistor is used for both the LED and the button.
    Figure 24: Circuit
  4. Write the Arduino program to implement the flowchart. Include comments explaining what the code is doing. The code must have comments to be approved by a TA
    1. First start a new sketch in the Arduino IDE
      1. Open the Arduino IDE
      2. Plug the Arduino/RedBoard into the computer
      3. In the Arduino IDE toolbar, go to Tools > Board > Select Arduino/Genuino Uno
      4. In the toolbar, go to Port and select the correct port
    2. In the Global Area, create the constants used to hold the pin numbers for the button and the LED (Figure 25).
      Figure 25: Constants
    3. In the Setup Area, use pinMode() to set up the LED and Button. The LED will be set to OUTPUT since it will be controlled by the program. The button will be set to INPUT since the program will receive data from the button (Figure 26).
      Figure 26: LED and Button Setup
    4. In the Loop Area, use digitalRead(), digitalWrite(), and a conditional to write the code that controls the button.
      1. Create a variable named buttonState, that will hold the input from the button (Figure 27).
        Figure 27: ButtonState Variable
      2. Use digitalRead() to set the buttonState variable to the current state of the button (Figure 28).
        Figure 28: DigitalRead ButtonState Variable
      3. Set up the conditional statement that will be used to control the LED. In this code, the conditional is controlled by the button state (Figure 29).
        Figure 29: Conditional Statement
      4. Use digitalWrite() to control the LED. Remember, we want the LED to be on when the button is pressed, and off otherwise.
        1. This line will turn the LED on (Figure 30).
          Figure 30: LED On
        2. This line will turn the LED off (Figure 31).
          Figure 30: LED OFF


2. Prototyping a Thermal Insulation Device

Competition Rules

The following rules must be observed at all times during the competition. Violation of any of these rules will result in disqualification.

  • The placement of the thermistor with respect to the lid may not be changed
  • The thermal insulating device may not be held while testing
  • External heat sources are prohibited
  • The jar of beeswax must be inside the container within 30 seconds of it being received
  • The jar of beeswax cannot be returned (no restarts)
  • A minimum of $0.40 must be used in the design of the insulating device

The competition will be judged by the minimal design ratio (MDR) (2) of the design. The design with the lowest MDR wins

(2)

In (2), IC is the insulating capacity, Cost is the cost of the container, TR is the temperature of the room, and TF is the final temperature read by the thermistor. Ask a TA for the room temperature

The insulating container will be built using the materials in Table 4. Select the materials carefully. Consider their cost and their use as an insulator. Review the competition ratio before purchasing materials

Table 4: Materials and Costs
Material Unit Cost Per Unit
Large foam cup 1 $0.50
Pack of clay 1 bag $0.20
Wool fabric 2 pieces $0.10
Cotton balls 3 balls $0.05
Popsicle sticks 1 $0.01
Paper cup 1 $0.40
Styrofoam pieces 5 $0.05
Tape 1 ft $0.10
Aluminum foil 1 ft2 $0.30
Plastic wrap 1 ft2 $0.02

NO RETURN POLICY: When calculating cost, ALL materials requested must be included, even if they were not used. Choose the materials carefully to avoid increasing the cost unnecessarily.

3. Competition Procedure

Building a Thermistor

Using the Arduino, the temperature change of the hot wax will be recorded over 10 minutes. The Arduino will read the temperature through the thermistor and print the values into the serial monitor.

  1. Carefully remove the existing circuit and wire the circuit according to the configuration in Figure 32. A 10 kΩ (If four-banded, Brown, Black, Orange, and Gold). If five-banded, (Brown, Black, Black, Red, and Gold) resistor should be used. Make sure that pin A0 is used, and the circuit is powered to 5V and grounded.
    Figure 32: Arduino Thermistor Wiring Diagram
  2. Download the Arduino Program to be used to operate the thermistor.
  3. There are missing components in the code. Read through the comments and insert code where necessary. After the program is completed and uploaded, open the Serial Monitor to check if the readings are correct (should be at or near 70 °F). Keep the circuit intact since it will be used to measure the temperature of the wax.
  4. The Arduino should be taking a temperature reading every 15 sec. The analog voltage value read through pin A0 should then be converted to degrees Fahrenheit. The temperature reading should be printed to the Serial Monitor along with the seconds timestamp of the reading.

Insulating Device Design

  1. Analyze the materials and consider the design options, keeping in mind the lab's specifications. Make preliminary sketches during this process.
  2. Sketch the design. Label the drawings clearly. Prepare a price list and write down the total cost for the insulating container based on the materials chosen. Receive approval of the design sketch from a TA.
  3. Build the insulating device based on the completed sketch. The TA will provide the materials needed for the design. If the design is modified during construction, note the changes and describe the reasons for them. If the modifications required more materials, update the price list and obtain approval. a reminder, materials that are purchased but ultimately to not end up in the final design are still counted towards the final cost of the device.

Competition

  1. Have a TA verify the fixed Arduino code. Run the program for approximately 30 sec to obtain an average room temperature. The data from the Arduino can be seen in the Serial Monitor on the top right corner of the Arduino IDE.
  2. Stop the program after 30 sec and check to ensure that the data was collected. Record the average room temperature provided by the TAs.
  3. The TA will bring the heated wax. Place the lid with the thermistor attached over the top of the wax. Be sure the top of the container is loosely covered with the lid.
  4. Do not adjust the thermistor from its position in the lid. Do not screw on the lid, just place it over the container. Warning: Be careful! The melted wax is hot!
  5. Restart the Arduino program. Once the temperature readings stop increasing, start timing the 10 minute run.
  6. The data from the thermistor will allow for further analysis. The Arduino data from the Serial Monitor will be used to calculate the insulating capacity (IC) for the competition ratio. DO NOT CLOSE OUT OF THE SERIAL MONITOR WINDOW. This will reset and erase all data previously displayed. There is no way to recover erased serial monitor data. After 10 min from the time the temperature readings stop increasing, copy and paste the data from the Serial Monitor into a Microsoft Excel file.

4. Data Analysis

  1. The data pasted from the Serial Monitor into Excel is not correctly separated into columns. To present the data in the correct format, highlight all the data, and go to the Data tab and select “Text to Columns” (Figure 33).
    Figure 33: Text to Columns
  2. In the Text-to-Columns wizard, select Delimited as the data type and click Next. Then select “Comma” as the delimiter, and hit “Finish”. Ensure that the data has been separated into two separate columns.
  3. Create a graph of the data using the X, Y Scatter template. First, select the data starting from where the temperature readings stops increasing (example below). Next go to the Insert tab, and click on the first Scatter option under the Charts group. This should create a new scatter plot, as shown in Figure 34.
    Figure 34: Scatter plot
  4. Next add axis labels and a trendline. First click on the graph, and then the green “+” icon next to it. Then, check off “Axis Titles, Chart Titles, and Trendline”. Click on the added labels to edit the text. When finished, the graph should look similar to Figure 35.
    Figure 35: Temperature vs. Time Graph of the Thermal Insulation Device
  5. Calculate the insulating capacity (IC) of the design. This will be done using the trendline equation. Right-click on the trendline and select “Format Trendline”. On the “Trendline Options” tab, ensure that the trendline is linear. Select the “Display Equation on Chart" option. The slope of this linear equation is the IC.
  6. Give the IC, final temperature, and total cost to the TA to enter the design's performance into the competition score sheet and calculate the MDR.

The lab work is now complete. Please clean up the workstation. Return all unused materials to a TA.

Assignment

Note: Part 2: Thermal Insulation Device Competition will be included in both lab report and team presentation. Part 1: Building an LED and Button Circuit DOES NOT need to be included in the lab report and team presentation.

Individual Lab Report

Follow the lab report guidelines laid out in the EG1004 Writing Style Guide in the Technical Writing section of the manual. Use the outline below to write this report. The LED and button circuit procedure does not need to be discussed.

  • Abstract
    • Briefly summarize the lab exercise. Include the competition results
  • Introduction
    • Discuss prototyping, the hardware and software components used in the lab, heat and heat transfer, all elements of the competition, and the design strategy and impact of rules, materials, and ratio on design strategy
  • Procedure
    • Materials
    • Describe the steps taken in the competition exercise in sufficient detail so that another person could follow the description and replicate the results
  • Data/Observations
    • Present and discuss all data collected during the exercise
  • Conclusion
    • Analyze the competition results using the data from the competition
    • Describe how the design’s performance could be improved. Recalculate the ratio to prove that design modifications would improve performance
    • Discuss what factors could affect the MDR and IC
    • Describe the Temperature vs Time graph. Discuss potential factors that could affect the graph readings that were recorded and the shape of the graph
  • Contribution Statement


Note: It is not unusual to experience instrumentation errors in this lab, leading to incorrect temperatures being recorded. Be sure to read How to Handle Unusual Data in the manual to learn how to handle this.

Remember: Lab notes must be taken. Experimental details are easily forgotten unless written down. EG1004 Lab Notes paper can be downloaded and printed from the EG1004 Website. Use the lab notes to write the Procedure section of the lab report. At the end of each lab, a TA will scan the lab notes and upload them to the Lab Documents section of the EG1004 Website. One point of extra credit is awarded if the lab notes are attached at the end of the lab report. Keeping careful notes is an essential component of all scientific practice.

Team PowerPoint Presentation

Follow the presentation guidelines laid out in the EG1004 Lab Presentation Format in the Technical Presentations section of the manual. When preparing the presentation, consider the following points.

  • What is the importance of prototyping and using Arduino?
  • What is the importance of minimal design?
  • How are materials selected in prototyping?
  • Why is it important to minimize heat loss?
  • What is the importance of the automation of proper data collection methods?
  • How can the design be improved?

References

Poff, Zach. (n.d.). “Resistor Color Code Chart.” Accessed August 11, 2021 from zachpoff.com