instructions.docx

Overview:

A force sensing resistor can be used to measure the weight of an object.  The resistor has several problems - its output changes depending on where on the pad the weight is located. In addition it takes a certain amount of weight before the FSR will respond with an output.  Finally the output tends to be jumpy, and it can be difficult to get a clean reading.  You will do some simple things to take a poorly functioning but inexpensive force sensor and make it into a useful weight sensor. 

Your Task:

Working in a small team, build the circuit that contains the force sensor.  Get a baseline for its performance.  Then modify the mechanical and software interface to the sensor and record the new performance.  

Step 1: Build the Circuit

 Your team will be given a force sensing resistor to work with for this assignment.  The FSR looks like this:

Weight sensor.jpg

 There are two leads and this device does not matter which one is connected to which side of the circuit.  The FSR is connected in a voltage divider circuit just like the photoresistor and the thermistor.  The schematic is shown below:

Weight Sensor schematic.png

In this schematic the output of the voltage divider is fed into pin A0.  Because of the stiffness of the lead from the FSR, it is recommended that you put the device on a slightly elevated flat surface, such as your parts pal.  We will use a cup to hold the M&M's being weighed.

Weight sensor setup.jpg

Now that you have the circuit set up you can attach the Arduino to your laptop and download and run the code "Weight_Sensor_Assignment.m" that is with this assignment on Canvas.  

Step 2: Getting a baseline of performance. 

The first time you run the code you will need to connect your Arduino to your MATLAB.  Find your COM port and use the a=arduino('com3','uno') command, with your com port -- or use the Connect_Arduino() function.  Head your script with clear and clc to keep from making MATLAB mad when you send a connect command more than one time.  Connect_Arduino() will not be bothered by this. 

Look at the code.  This is a modified version of the monitoring code used in previous weeks.  The While loop keeps the software constantly running.  To stop the program hold down the "control" key (Command key in Mac) and type a "C".  That command does not disconnect your Arduino and MATLAB, it just stops the program from running.  

When you run the code you will see a plot appear showing the output of your weight sensor.  Place the cup on your sensor and as the data is gathered add M&M's to the cup and watch the weight sensor respond.  Add 5 M&M's at a time.  Initially the sensor will not respond to the M&M's until enough weight is in the cup and then you should see a step increase each time you add weight.  If the graph is being created too quickly for your team you can modify the number inside the pause() command to slow it down.  When you have a nice graph showing the response from 0 M&M's to some large number, you can stop the program by doing a CTL/C and save the figure as a .png file (SAVE AS - do not use the default matlab figure type). 

Step 3:  Fix stuff

Mechanical:

You have been given some washers and a second cup.  Place the washers inside the second cup and place your measuring cup inside that (to keep the M&M's clean) to start your measurement at a weight your sensor can more reliably see. 

Create a target to set your cup on using the thin plastic sheet with the circle on it.  Line this up with your sensor and use scotch tape to hold things in one place. 

Software:

The code has a place for you to add an running average.  You should use a for loop to do this.  If you want to average 5 numbers together start with a for statement like:  for index = 1:5  If you want 10 samples make it for index = 1:10.  Remember the for loop needs and "end" statement.  There is a comment in your code to show you were that goes.  

Next you need to change some things inside the for loop.  Each time the loop runs you want to:

    Read a value from your sensor, indexed to this new for-loop ( i.e.  weight(index)=readVoltage.......)

    Accumulate that value with your other values to get a running sum

Once you leave the for-loop you want to divide that sum by the number of steps in your for loop. You will want to change the plot so now you are plotting the average value instead of the weight.  

Step 4:

Now do the same performance experiment as before with the fixes.  Record your new performance on your graph.  Save the graph as before and call it something like Weight Sensor Improved.