Hi all,
I have a project that I need to manufacture a chair that prevent pressure sores using fsr sensors
The seat will have 9 fsr sensors and the backrest will have 4 more sensors.
The sensors are connected to Arduino and the user is presented with a GUI using processing software.
We have a problem in the GUI.
The alert system will include two types of alert algorithms. The first is an alert whenever the pressure exceeds the determined pressure threshold, while the second is a permanent alert every two hours when the sensors don’t detect change in the pressure which indicates that the user stayed in the same position.
The equation for the threshold is:
Pthreshold = (24 / cbrt(1 + 3 * exp(x))) + 6.5; // Threshold calculation
The fsr GUI metrix should look like this:
I have an Arduino code and I need processing code.
int fsrPin1 = A0;
int fsrPin2 = A1;
int fsrPin3 = A2;
int fsrPin4 = A3;
int fsrPin5 = A4;
int fsrPin6 = A5;
int fsrReading1;
int fsrReading2;
int fsrReading3;
int fsrReading4;
int fsrReading5;
int fsrReading6;
int fsrVoltage1;
int fsrVoltage2;
int fsrVoltage3;
int fsrVoltage4;
int fsrVoltage5;
int fsrVoltage6;
unsigned long fsrResistance1;
unsigned long fsrResistance2;
unsigned long fsrResistance3;
unsigned long fsrResistance4;
unsigned long fsrResistance5;
unsigned long fsrResistance6;
unsigned long fsrConductance1;
unsigned long fsrConductance2;
unsigned long fsrConductance3;
unsigned long fsrConductance4;
unsigned long fsrConductance5;
unsigned long fsrConductance6;
long fsrForce1;
long fsrForce2;
long fsrForce3;
long fsrForce4;
long fsrForce5;
long fsrForce6;
float pressure1;
float pressure2;
float pressure3;
float pressure4;
float pressure5;
float pressure6;
float Pthreshold ;
int set = 0;
float t;
String data = “”;
unsigned long timer1;
void setup(void) {
Serial.begin(9600);
pinMode(fsrPin1, INPUT);
pinMode(fsrPin2, INPUT);
pinMode(fsrPin3, INPUT);
pinMode(fsrPin4, INPUT);
pinMode(fsrPin5, INPUT);
pinMode(fsrPin6, INPUT);
}
void loop(void) {
// Serial.println(“test”);
fsrReading1 = analogRead(fsrPin1);
fsrReading2 = analogRead (fsrPin2);
fsrReading3 = analogRead (fsrPin3);
fsrReading4 = analogRead (fsrPin4);
fsrReading5 = analogRead (fsrPin5);
fsrReading6 = analogRead (fsrPin6);
//Serial.println(fsrReading1);
fsrVoltage1 = map(fsrReading1, 0, 1023, 0, 5000);
/*fsrResistance1 = 5000 - fsrVoltage1; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance1 = 10000; // 10K resistor
fsrResistance1 /= fsrVoltage1;/
// V_resistor = Vcc * 10K /(10K + FSR_resistance
// FSR_resistance = Vcc*10K/(V_Resistor) - 10K
if (fsrVoltage1 > 0)
{
fsrResistance1 = 5000.0 * 10000 / (fsrVoltage1) - 10000;
fsrConductance1 = 1000000; // we measure in micromhos
fsrConductance1 /= fsrResistance1;
if (fsrConductance1 <= 1000) {
fsrForce1 = fsrConductance1 / 80;
} else {
fsrForce1 = fsrConductance1 - 1000;
fsrForce1 /= 30;
}
}
else
{
fsrResistance1=0;
fsrConductance1 = 0;
fsrForce1 = 0;
}
Serial.println();
Serial.println("fsrVoltage1 = " + String(fsrVoltage1));
Serial.println("fsrResistance1 = " + String(fsrResistance1));
Serial.println("fsrConductance1 = " + String(fsrConductance1));
Serial.println("fsrForce1 = " + String(fsrForce1));
Serial.println();
delay(500);
fsrVoltage2 = map(fsrReading2, 0, 1023, 0, 5000);
fsrResistance2 = 5000 - fsrVoltage2; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance2 *= 10000; // 10K resistor
fsrResistance2 /= fsrVoltage2;
fsrConductance2 = 1000000; // we measure in micromhos
fsrConductance2 /= fsrResistance2;
if (fsrConductance2 <= 1000) {
fsrForce2 = fsrConductance2 / 80;
} else {
fsrForce2 = fsrConductance2 - 1000;
fsrForce2 /= 30;
}
fsrVoltage3 = map(fsrReading3, 0, 1023, 0, 5000);
fsrResistance3 = 5000 - fsrVoltage3; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance3 *= 10000; // 10K resistor
fsrResistance3 /= fsrVoltage3;
fsrConductance3 = 1000000; // we measure in micromhos
fsrConductance3 /= fsrResistance3;
if (fsrConductance3 <= 1000) {
fsrForce3 = fsrConductance3 / 80;
} else {
fsrForce3 = fsrConductance3 - 1000;
fsrForce3 /= 30;
}
fsrVoltage4 = map(fsrReading4, 0, 1023, 0, 5000);
fsrResistance4 = 5000 - fsrVoltage4; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance4 *= 10000; // 10K resistor
fsrResistance4 /= fsrVoltage4;
fsrConductance4 = 1000000; // we measure in micromhos
fsrConductance4 /= fsrResistance4;
if (fsrConductance4 <= 1000) {
fsrForce4 = fsrConductance4 / 80;
} else {
fsrForce4 = fsrConductance4 - 1000;
fsrForce4 /= 30;
}
fsrVoltage5 = map(fsrReading5, 0, 1023, 0, 5000);
fsrResistance5 = 5000 - fsrVoltage5; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance5 *= 10000; // 10K resistor
fsrResistance5 /= fsrVoltage5;
fsrConductance5 = 1000000; // we measure in micromhos
fsrConductance5 /= fsrResistance5;
if (fsrConductance5 <= 1000) {
fsrForce5 = fsrConductance5 / 80;
} else {
fsrForce5 = fsrConductance5 - 1000;
fsrForce5 /= 30;
}
fsrVoltage6 = map(fsrReading6, 0, 1023, 0, 5000);
fsrResistance6 = 5000 - fsrVoltage6; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance6 *= 10000; // 10K resistor
fsrResistance6 /= fsrVoltage6;
fsrConductance6 = 1000000; // we measure in micromhos
fsrConductance6 /= fsrResistance6;
if (fsrConductance6 <= 1000) {
fsrForce6 = fsrConductance6 / 80;
} else {
fsrForce6 = fsrConductance6 - 1000;
fsrForce6 /= 30;
}
// Calculation pressure [kPa]
pressure1 = fsrForce1 * 1.9745;
pressure2 = fsrForce3 * 1.9745;
pressure3 = fsrForce4 * 1.9745;
pressure4 = fsrForce5 * 1.9745;
pressure5 = fsrForce6 * 1.9745;
if ((pressure1 > 0 || pressure2 > 0 || pressure3 > 0 || pressure4 > 0 || pressure5 > 0 || pressure6 > 0) && set == 0) {
set = 1;
timer1 = millis();
}
else {
set = 0;
timer1 = millis();
Pthreshold = 0;
}
long c = timer1 / 1000;
t = float (c) / 60; // Conversion to minutes
float x = (t - 74) / 4;
Pthreshold = (24 / cbrt(1 + 3 * exp(x))) + 6.5; // Threshold calculation
/data = String(pressure1) + “,” + String(pressure2) + “,” + String(pressure3) + “,” + String(pressure4) + “,” +
String(pressure5) + “,” + String(Pthreshold);/
data = String(fsrReading1) + “,” + String(pressure2) + “,” + String(pressure3) + “,” + String(pressure4) + “,” +
String(pressure5) + “,” + String(Pthreshold);
Serial.println(data);
delay(1000);
}
pls help me! I need to submit this project ASAP.