confidence interval measurement for resisnance
USE-INSPIRED DESIGN PROJECT I Fall 2017
Arduino Force Sensitive Resistor (FSR) Lab This three-part lab will explore the properties and applications of force sensitive resistors (FSRs) using Arduino programming. In this lab, you will:
1. read the analog voltage of an FSR, 2. use the analog voltage to vary the brightness of a LED, 3. convert the analog voltage into a qualitative (i.e., text) measurement of the force applied
to the FSR, 4. convert the analog voltage into a quantitative (i.e., numerical) measurement of the force
applied to the FSR, and 5. evaluate the precision and accuracy of the FSR measurements.
This is an INDIVIDUAL assignment. Data collected in teams of 2-3 students must be used to answer the 6 questions at the end of the assignment on your own. Submit your responses as a Word, Excel, or PDF document on Blackboard. The assignment is due on Thursday, October 12, before 12:01 am. Label your file as "Name – Arduino FSR Lab”.
What is a Force Sensitive Resistor (FSR)? An FSR is a resistor that changes its resistive value (in ohms, Ω) depending on how much it is pressed – their resistance goes down the more the sensor is pressed. FSRs are used to detect physical pressure or force. They are made of two conductive layers separated by a spacer. The Interlink 402 model we will use in class is shown in Figure 1. The Interlink 402 has a 0.5 in. diameter active area and is 0.02 in. thick. It can detect 0 to 20 lbs. (0 to 100 N) applied evenly on its 0.125 in.2 surface area. It uses less than 1 mA of current, depending on the pullup or pulldown resistors and supply voltage used, and can be powered by nearly any power source. It costs $7. Additional information on the use of the sensor can be found here: https://learn.adafruit.com/force-sensitive-resistor-fsr/using-an-fsr. The datasheet for the Interlink 402 can be found here: https://cdn-learn.adafruit.com/assets/assets/000/010/126/original/fsrguide.pdf.
Figure 1: The Interlink 402 model, externally (left) and internally (right)
The resistance range of the Interlink 402 varies from infinite (i.e., an open circuit) under no pressure to 200 Ω under maximum pressure. It is important to note that the relationship between force and resistance is non-linear, as shown by the log/log graph in Figure 2. (Note: to convert mass in grams to force in N, divide by 100.) The resistance of the FSR quickly changes from infinite to 100 kΩ at especially low-force measurements.
Figure 2: Graph of resistance vs. mass for the Interlink 402
FSR Lab Part 1 – Skills
Step 0: Getting Started In teams of 2-3 students, collect all parts shown in Figure 3 from your instructor, including: Arduino Uno and USB cable, FSR, alligator clips, breadboard, foam circle and foam square, two 100 Ω resistors, two 1 kΩ resistors, two 10 kΩ resistors, two LEDs, and jumper wires.
Figure 3: Parts for the lab
Next, sign and return the Arduino Kit contract to your instructor, and download the Arduino 1.8.4 IDE software here: https://www.arduino.cc/en/Main/Software. Connect your Arduino to
your computer via the USB cable, and check that the proper port is selected by choosing Serial Port under Tools. Step 1: Reading Analog Voltages The force applied to the FSR can be determined from the voltage measured across the FSR. The easiest way to measure the voltage across the FSR is to build a voltage divider. A voltage divider is a simple circuit which can be used to compute the voltage across one of two or more resistors connected in series. The simplest example of a voltage divider is two resistors connected in series, with the input voltage applied across the resistor pair and the output voltage emerging from the connection between them, as in Figure 4. The output voltage, VO, in Figure 4 can then be calculated using Equation 1, where VCC is the power supply voltage (+ 5 V). Note that the output voltage is inversely proportional to the FSR resistance:
)FSRR( R
VV CCO + = (1)
Figure 4: Arduino setup and circuit schematic for reading analog voltages
Build the voltage divider circuit shown in Figure 4. Connect one end of the FSR to power on the Arduino (+5 V) and the other end to the analog input, a0. (In this configuration, the analog reading for the FSR ranges from 0 V, ground, to about +5 V, about the same as the power supply.) Next, connect one end of a 10 kΩ resistor to a0 and the other end to ground.
WARNING! Because FSRs are resistors, they are non-polarized, meaning it does not matter which end is connected to power and which end is connected to the analog input. However, FSRs are often plastic. The best way to connect FSRs is to plug them into a breadboard or use a clamp-style connector. It is possible to solder onto the tabs, but you must be very fast or else you will melt the plastic and ruin the FSR. Don’t attempt to solder directly to your FSR unless you are absolutely sure you have the skills to do so.
Compile and run the following code on the Arduino. (The code is also available to be copied on Blackboard under Resources. Make sure that comments do not overflow onto multiple lines.) Then, open the Serial Monitor under Tools in the Arduino IDE platform, and observe how the analog reading for the FSR varies as you apply more or less pressure to the FSR with your fingertips. What happens to the analog reading as the pressure on the FSR increases? What happens to the output voltage? How does what you observe compare with Equation 1?
// Reading Analog Voltages. int fsrPin = 0; // the FSR and 10K resistor are connected to a0 int fsrReading; // the analog reading from the FSR voltage divider float fsrReading_f; // the analog reading from the FSR voltage divider in float (vs. integer) form float fsrVoltage; // the analog reading converted to voltage void setup(void) { Serial.begin(9600); // initializes variables } void loop(void) { fsrReading = analogRead(fsrPin); // takes analog reading Serial.print("Analog reading = "); Serial.println(fsrReading); // prints analog reading fsrReading_f = fsrReading * 1.0; // converts analog reading from integer form to float form fsrVoltage = fsrReading_f * 5.0 / 1023.0; // converts analog reading into analog voltage, analog reading ranges from about 0 to 1023 which maps to range from 0 V to 5 V Serial.print("Voltage reading in V = "); Serial.println(fsrVoltage); // prints analog voltage of FSR Serial.println("--------------------"); // prints separating line delay(100); // waits 100 milliseconds until next reading }
Step 2: Lighting Up a LED Use the analog reading from the FSR to determine how bright a LED is. Wire the FSR voltage divider the same as you did in Step 1, and add a LED to PWM pin 11 (see Figure 5). The PWM (pulse-width modulating) pin can be used to create a pulse that varies with the integer reading from the analog input. As the width of the pulse changes, the brightness of the LED changes. Incorporate the syntax below into your existing code. (The syntax is also available to be copied on Blackboard under Resources.) Compile and run the code on the Arduino. What happens to the LED as the pressure applied to the FSR increases? Why does this happen?
Figure 5: Arduino setup and circuit schematic for lighting up a LED
// Lighting up a LED. int fsrPin = 0; // the FSR and 10K resistor are connected to a0 int LEDpin = 11; // the LED is connected to PWM pin 11 int fsrReading; // the analog reading from the FSR voltage divider int LEDbrightness; // the analog reading converted to LED brightness void setup(void) { Serial.begin(9600); // initializes variables pinMode(LEDpin, OUTPUT) ; // initializes pins } void loop(void) { fsrReading = analogRead(fsrPin); // takes analog reading LEDbrightness = map(fsrReading, 0, 1023, 0, 255); // maps analog reading into LED brightness, analog reading ranges from about 0 to 1023 which maps to the range used by analogWrite (0-255) analogWrite(LEDpin, LEDbrightness); // writes LED brightness to pin 11 }
Step 3: Qualitatively Measuring Force Use the analog reading from the FSR to measure the force being applied to the sensor in a qualitative manner. Once again, open the Serial Monitor under Tools in the Arduino IDE platform, and observe how the analog reading for the FSR varies as you apply more or less pressure to the FSR. Based on your observations, create thresholds for the following five pressures: no pressure, light touch, light squeeze, medium squeeze, and big squeeze. For example, you might find that a “light touch” corresponds to an analog reading of approximately 10 to 200. (Tip: you may want to increase the length of the delay in your code, to make identifying these values easier.)
Next, update the syntax below with the thresholds you found, and add the updated syntax to your existing code. (The syntax is also available to be copied on Blackboard under Resources.) Compile and run the code on the Arduino. Does the code operate as you expected?
// Qualitatively Measuring Force. int fsrReading; // the analog reading from the FSR voltage divider // thresholds for no pressure, normal pressure, and excessive pressure, qualitatively determined if (fsrReading < 10) { Serial.println(" - No pressure"); // prints “no pressure” if analog reading is less than 10 } else if (fsrReading < 800) { Serial.println(" – Normal pressure"); // prints “no pressure” if analog reading is between 10 and 800 } else { Serial.println(" - Excessive pressure"); // prints “no pressure” if analog reading is greater than 800 }
STOP! You have now completed Part 1 of the FSR Lab. Demonstrate to the instructor or the grader that your circuit is able to read analog voltages from the FSR, light up a LED, and qualitatively measure force on the FSR. Once you are checked off on Part 1, you may proceed to Part 2.
FSR Lab Part 2 – Application
Step 4: Quantitatively Measuring Force Use the analog reading from the FSR to measure the force being applied to the sensor in a quantitative manner, and evaluate the accuracy of the force measurement. To do this, first measure the FSR resistance for the known masses in Table 1 using the precision masses (50g, 100g, and 200g) provided in class. Repeat each measurement three times.
Table 1: Measured FSR Resistance Values
Mass (in grams) FSR Resistance (in ohms)
1 2 3 100 150 200 250 300 350
TIP! The tops and bottoms of the precision masses are slightly too concave to properly press or squeeze the FSR. Test this out yourself – if you put a mass on the FSR, does it produce a reading? To circumvent this issue, use the provided foam square and foam circle to create the configuration shown at left. The foam conforms to the mass and the FSR, allowing the FSR to be squeezed. Make sure that the foam square is lined up with the active area of the FSR for accurate measurement.
The syntax to measure FSR resistance is shown below. Add the syntax to your existing code, and compile and run the code on the Arduino. (The syntax is also available to be copied on Blackboard under Resources.) Then, open the Serial Monitor under Tools in the Arduino IDE platform to record the FSR resistance for each weight. (Tip: you may want to increase the length of the delay in your code, to make identifying these values easier.)
// Measuring FSR Resistance. float fsrVoltage; // the analog reading converted to voltage float fsrResistance; // the FSR voltage converted to resistance if (fsrVoltage == 0) { Serial.println("No pressure"); // prints “no pressure” if fsrVoltage is equal to 0 } else { // Vo = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V // so FSR = ((Vcc - Vo) * R) / Vo fsrResistance = 5.0 - fsrVoltage; // subtracts fsrVoltage from Vcc fsrResistance *= 10000; // multiples new fsrResistance by R in ohms fsrResistance /= fsrVoltage; // divides new fsrResistance by fsrVoltage Serial.print("FSR resistance in ohms = "); Serial.println(fsrResistance); // prints resistance of FSR in ohms }
Next, calculate an average FSR resistance for each mass in Table 1 based on your observations. Create a scatterplot with average FSR resistance in ohms on the x axis and force in Newtons on the y axis. Fit a quadratic trendline to your data since the relationship between mass and resistance non-linear. (Do not set the intercept to zero.) Update the syntax below with the equation of the trendline you found, and add the updated syntax to your existing code. (The syntax is also available to be copied on Blackboard under Resources.) Compile and run the code on the Arduino.
// Measuring FSR Force. float fsrResistance; // the FSR voltage converted to resistance float fsrForce; // the FSR resistance converted to force
if (fsrVoltage == 0) { Serial.println("No pressure"); // prints “no pressure” if fsrVoltage is equal to 0 } else { fsrForce = f(fsrResistance); // the FSR force as a function of FSR resistance, input your trendline for force in terms of resistance here Serial.print("FSR force in Newtons = "); Serial.println(fsrForce); // prints force on FSR in Newtons }
Lastly, measure the force being applied to the FSR for the known masses in Table 2. Repeat each measurement three times.
Table 2: Measured FSR Force Values
Mass (in grams) FSR Force (in Newtons)
1 2 3 100 150 200 250 300 350
STOP! You have now completed Part 2 of the FSR Lab. Demonstrate to the
instructor or the grader that you have completed Table 1 and Table 2. Once you are checked off on Part 2, you may proceed to Part 3. Make sure that all team members have the Arduino code used in Step 4, as well as the values in Table 1 and Table 2. Next, answer Questions 1-6 below, and submit your responses as a Word, Excel, or PDF document on Blackboard. Questions are to be answered individually.
FSR Lab Part 3 - Interpretation Step 5: Demonstrating Understanding Answer the following questions to demonstrate your individual understanding of your Arduino code, data collection, and data analysis. Question 1: Provide a copy of your final Arduino code. Create a flowchart that visually depicts the actions that result from your code. Break your code down into blocks to simplify your flowchart and ensure that descriptions written in your own words are clear and comprehendible. The overall flowchart should clearly describe what your code does.
Question 2: Provide a copy of your Force vs. FSR resistance scatterplot. Make sure to include your original data from Table 1. What was the goodness-of-fit R-squared value for the quadratic trendline you fit to the data? Does your R-squared value improve if you fit a linear trendline? Does it improve if you fit a cubic trendline? What would be the disadvantage of fitting a cubic, or other higher- order, trendline? Question 3: A confidence interval (CI) is a measurement used to describe the amount of certainty or reliability associated with a sample estimate of a population parameter, such as a mean. Confidence intervals are often reported as the 95% confidence interval. A 95% confidence interval means that, if a sample was collected 100 times, 95 times the calculated confidence interval would contain the true population parameter, and 5 times the calculated confidence interval would not. The confidence interval for the mean of a sample can be calculated using Equation 2, where M is the mean, s is the standard deviation, n is the size of the sample, and t is the t-distribution value corresponding to the sample size and desired percent confidence level.
n s
tMCI ±= (2)
Using Equation 2, calculate a 95% confidence interval for the FSR resistance associated with each of the six masses in Table 1 (6 total calculations). (The t-value for a 95% confidence interval and sample size of 3 is 4.30.) How does the precision of the resistance measurement change as the mass becomes heavier? Explain why this change happens. Question 4: Calculate an average measured weight for each of the six masses in Table 2. Then, compute the percent error between the average measured weight (Measured) and the known weight (Accepted) using Equation 3 (6 total calculations). Make sure to include your original data from Table 2. Would you say that this model of FSR is very accurate? What would be the advantages of using it?
100x |Accepted|
|AcceptedMeasured| error%
− = (3)
Question 5: List 3-4 possible sources of error in this lab. What steps could you take to mitigate these sources? Question 6: List 1-2 ideas for each of the following prompts:
• How could you apply the skills and technologies used in this lab to the improvement of the Oral-B electric toothbrush that you dissected in class?
• How could you apply the skills and technologies used in this lab to a different project of your choosing?