Assignment 2: datalogging
by Nont
I use Flexiforce as a sensor for testing in this datalogging project.
And then, I just send raw data from FlexiForce to processing via serial to check the character of the data of this sensor.

Picture 1:

Picture A: When I let the sensor stretch as original form, graph was very smooth (A).

Picture B: When I bent the sensor to the position that suitable for pressing, the data had some noise(B).

Picture C: When I started pressing it, the data was dramatically changed (C).

Picture 2: Form this testing, I found that it was very dificult to estimate giving the same value of force to the sensor again.
And character of graph was very unstable.
'+++This is a code for pic+++ '
' Define ADCIN parameters
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 20 ' Set sampling time in uS
SensorValue var word
' serial pins and data reate:
tx var portc.6
rx var portc.7
n9600 con 16468
' Set PORTA to all input
TRISA = %11111111 \\
' Set up ADCON1
ADCON1 = %10000010
Main:
' read sensor on pin RA0:
ADCin 0, sensorValue
serout2 tx, n9600, [sensorValue]
pause 100
Goto main
++This is a code for processing++
/*
Datalogger
modify form Tom Igoe Datalogger Code
*/
import processing.serial.*;
Serial myPort; // The serial port
// initial variables: int i = 1; // counter int inByte = -1; // data from serial port
void setup () {
size(350, 280); // window size
// List all the available serial ports println(Serial.list()); //I use COM4 so I open Serial.List()[1] myPort = new Serial(this, Serial.list()[1], 9600); // set inital background: background(100);
} void draw () {
if (myPort.available() > 0) {
inByte = myPort.read();
serialEvent();
}
}
void serialEvent () {
// draw the line:
stroke(255,255,75);
line(i, height, i, (height - inByte)-20);
// at the edge of the screen, go back to the beginning:
if (i >= width) {
i = 0;
background(100);
}
else {
i++;
}
}