Difference between revisions of "PIC32MX: Interfacing with Force Sensors from a Scale"

From Mech
Jump to navigationJump to search
Line 21: Line 21:
1. colorbars:
1. colorbars:


continuously displaying the force applied onto each force sensor by using 4 bars that will grow or shrink depending on the amplitude of mass (force). The bars will also show the amplitude of the mass by changing colors. When 0 or little force is applied, then corresponding bar is black colored, at the max force, the bar is orchid (pink) colored.
continuously displaying the force applied onto each force sensor by using 4 bars that will grow or shrink depending on the amplitude of mass (force). The bars will also show the amplitude of the mass by changing colors. When 0 or little force is applied, then corresponding bar is black colored, at the max force, the bar is orchid (pink) colored.
2. xy-plot:
2. xy-plot:


continuously displays the x- and y- position of the center of balance calculated between all 4 sensors with a dot on a xy-coordinate plane. So, if the person shifts his weight to the right side of scale, then the dot will move to the right in the x direction. If the person shifts his weight to the front of the sensor, then the dot will move up in the y direction.
continuously displays the x- and y- position of the center of balance calculated between all 4 sensors with a dot on a xy-coordinate plane. So, if the person shifts his weight to the right side of scale, then the dot will move to the right in the x direction. If the person shifts his weight to the front of the sensor, then the dot will move up in the y direction.
3. x-position vs. time:
3. x-position vs. time:


continuously plots a dot for the x-position along a time axis. This plot will be useful to see how much the person shifts his/her weight to the left or right (sagittal plane) over time. Due to the window size and the speed of processing, the points will be plotted over a time period of about 20 seconds.
continuously plots a dot for the x-position along a time axis. This plot will be useful to see how much the person shifts his/her weight to the left or right (sagittal plane) over time. Due to the window size and the speed of processing, the points will be plotted over a time period of about 20 seconds.
4. y-position vs. time:
4. y-position vs. time:


continuously plots a dot for the y-position along a time axis. This plot will be useful to see how much the person shifts his/her weight forward or backwards (coronal or frontal plane) over time. The code for this section is essentially the same as the x-position but edited to show y-position.
continuously plots a dot for the y-position along a time axis. This plot will be useful to see how much the person shifts his/her weight forward or backwards (coronal or frontal plane) over time. The code for this section is essentially the same as the x-position but edited to show y-position.


General Notes:
General Notes:


Our code was written with the assumption that the inputs from the PIC (that initially comes from the 4 force sensors) will come in the form of a 4x1 array. It does not actually arrive in that form from the PIC, it actually arrives as a string of floats separated by spaces ending with a new line. The new line is deleted and the floats are extracted out, normalized between 0-255, and put into the "mass" array. All of the normalization, window dimension parameters, rectangle dimensions, etc. were set up with the 0-255 range and 1000x700 window size in mind. So if the values are not between 0-255 or the window size is altered, almost all of following code will be messed up. The x-position vs. time and y-position vs. time plots are not implemented as independent functions. The code for these plots are found at the very end of colorbars();.
Our code was written with the assumption that the inputs from the PIC (that initially comes from the 4 force sensors) will come in the form of a 4x1 array. It does not actually arrive in that form from the PIC, it actually arrives as a string of floats separated by spaces ending with a new line. The new line is deleted and the floats are extracted out, normalized between 0-255, and put into the "mass" array. All of the normalization, window dimension parameters, rectangle dimensions, etc. were set up with the 0-255 range and 1000x700 window size in mind. So if the values are not between 0-255 or the window size is altered, almost all of following code will be messed up. The x-position vs. time and y-position vs. time plots are not implemented as independent functions. The code for these plots are found at the very end of colorbars();.

Revision as of 23:33, 8 February 2010

Original Assignment

Do not erase this section!

Your assignment is to use four analog inputs to continuously read four force sensors taken from a bathroom scale, and to display them on a PC screen as bars whose length corresponds to the force at the sensors. You will use Processing for the PC data acquisition and graphics.

Overview

Summarize briefly what the page is about.

Circuit

Include a schematic and give any part numbers. A photo of your circuit is OK, but not as a replacement for a schematic.

Code

Where possible, make it a single piece of well-commented cut-and-pastable code, or at least make each function that way, so others can easily copy it. Most comments should be in the code itself; outside the code (on the wiki) should only be explanatory comments that are too cumbersome to include in the code.

The Processing portion of our lab involves 4 sections:

1. colorbars:

continuously displaying the force applied onto each force sensor by using 4 bars that will grow or shrink depending on the amplitude of mass (force).  The bars will also show the amplitude of the mass by changing colors.  When 0 or little force is applied, then corresponding bar is black colored, at the max force, the bar is orchid (pink) colored.
             

2. xy-plot:

continuously displays the x- and y- position of the center of balance calculated  between all 4 sensors with a dot on a xy-coordinate plane.  So, if the person shifts  his weight to the right side of scale, then the dot will move to the right in the x  direction. If the person shifts his weight to the front of the sensor, then the dot will move up in the y direction.
           

3. x-position vs. time:

continuously plots a dot for the x-position along a time axis.  This plot will be useful to see how much the person shifts his/her weight to the left or right (sagittal plane) over time.  Due to the window size and the  speed of processing, the points will be plotted over a time period of about 20 seconds.
                       

4. y-position vs. time:

continuously plots a dot for the y-position along a time axis.  This plot will be useful to see how much the person shifts his/her weight forward or backwards (coronal or frontal plane) over time.  The code for this section is essentially the same as the x-position but edited to show y-position.
                     

General Notes:

Our code was written with the assumption that the inputs from the PIC (that initially comes from the 4 force sensors) will come in the form of a 4x1 array.  It does not actually arrive in that form from the PIC, it actually arrives as a string of floats separated by spaces ending with a new line.  The new line is deleted and the floats are extracted out, normalized between 0-255, and put into the "mass" array.  All of the  normalization, window dimension parameters, rectangle dimensions, etc. were set up  with the 0-255 range and 1000x700 window size in mind.  So if the values are not between 0-255 or the window size is altered, almost all of following code will be messed up.  The x-position vs. time and y-position vs. time plots are not implemented as independent functions.  The code for these plots are found at the very end of colorbars();.